求助:怎样控制才使得文本框不能输入数字以外的字符?? IE: <input onkeypress="return /\d/.test(String.fromCharCode(event.keyCode));" /> IE||FF<input onkeyup="value=value.replace(/\D/g,'')"> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <input type=text onkeypress="if ((event.keyCode < 45 || event.keyCode > 57)&&event.keyCode!=32) event.returnValue = false;"> function CheckInteger(Field, FieldTitle){ if (Field.value != "") { for (i = 0; i < Field.value.length; i++) { ch = Field.value.charAt(i); if ( (ch < '0' || ch > '9') && ch != '-' ) { alert("\"" + FieldTitle + "\"中只能输入数字."); Field.focus(); return false; } } } return true;} <input type="text" onkeyup="value=value.replace(/^[0-9-\.]*$/g,'') " > <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title></title> </head> <body> <form name="form1"> <input name='0103' value="OK"> <input name='aa' value="aa"> </form> <script language="Javascript"> alert(document.form1.all("0103").value) alert(document.form1.aa.value); </script> </body> </html> 关于DIV隐藏和关闭问题 紧急求助:js读取注册表时,提示‘无法打开注册表键值’!! lhgdialog的皮肤问题 关于JS调用XML中DOM的调用。。老提示找不到属性和方法。。 紧急!!js悬停时出现菜单.鼠标可移到菜单中操作其他 求助:如何使<select>框变化 有人说javascript可以连接数据库,甚至java可以做的javascript都可以做,是不是这么回事啊??? 请问所有中文标点的Unicode码是什么?最好是一个区间值 高分求助:layer如何居中? 很菜的问题,高分求救,答者有分!(在线等……) 超简单问题 JS判断空字符串 顶者有分 如何让整个页面不可用?
{
if (Field.value != "")
{
for (i = 0; i < Field.value.length; i++)
{
ch = Field.value.charAt(i);
if ( (ch < '0' || ch > '9') && ch != '-' ) {
alert("\"" + FieldTitle + "\"中只能输入数字.");
Field.focus();
return false;
}
}
}
return true;
}
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body>
<form name="form1">
<input name='0103' value="OK">
<input name='aa' value="aa">
</form>
<script language="Javascript">
alert(document.form1.all("0103").value)
alert(document.form1.aa.value);
</script>
</body>
</html>