正则:
三个子条件的与:1,没有小数点和数字外的其它数字,2,小数点不在最前,3,小数点不在最后。
<INPUT type="text" id=text1  >
<INPUT type="button" value="Button" onclick="check(text1.value)">
<SCRIPT LANGUAGE=javascript>
<!--
function check(str){
renot=/[^\.\d]/;
repre=/^\./;
repost=/\.$/;
if(!renot.test(str) && !repre.test(str)&& !repost.test(str)){
alert("字符合法")
}
else{alert("字符非法")}
}
//-->
</SCRIPT>