<script language="JavaScript" type="text/javascript"> function checkNum(obj) { var re = /^-?[1-9]*(\.\d*)?$|^-?0(\.\d*)?$/; if (!re.test(obj.value)) { alert("非法数字"); obj.value=""; obj.focus(); return false; } } </script>
<input name="rate" type="text"onkeyup="checkNum(this)" />