<html> <head> <script type="text/javascript"> function isNaN() { var re = /^\d+$/; for (i = 0; i < document.form.length; i++) { var str = document.form.all(i).value; if (str.match(re) == null) { str = str.substr(0, str.length - 1); document.form.all(i).value =str; } } } </script> </head> <body> <form action="javascript:;" name="form"> <input type="text" οnkeyup="isNaN()"> </form> </body> </html>
只能输入数字的文本框(不能输入小数点)
最新推荐文章于 2023-02-15 11:38:44 发布