<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" onkeyup="isNaN()">
</form>
</body>
</html>
只能输入数字的文本框(不能输入小数点)
最新推荐文章于 2024-10-12 09:54:15 发布