输入身份证的输入框必须输入数字怎么写?
<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
<title>js 只能输入数字和小数点</title>
<script language="JavaScript" type="text/javascript">
function clearNoNum(obj)
{
//先把非数字的都替换掉,除了数字和.
obj.value = obj.value.replace(/[^\d.]/g,"");
//必须保证第一个为数字而不是.
obj.value = obj.value.replace(/^\./g,"");
//保证只有出现一个.而没有多个.
obj.value = obj.value.replace(/\.{2,}/g,".");
//保证.只出现一次,而不能出现两次以上
obj.value = obj.value.replace(".","$#{1}quot;).replace(/\./g,"").replace("$#{1}quot;,".");
}
</script>
</head>
<body>
<!--把下面代码加到<body>与</body>之间-->
只能输入数字和小数点的文本框:<input id="input1" onkeyup="clearNoNum(this)">
</body>
</html>
报js错误,求个正确的能运行的。谢谢。最后93分了,群给你了
<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
<title>js 只能输入数字和小数点</title>
<script language="JavaScript" type="text/javascript">
function clearNoNum(obj)
{
//先把非数字的都替换掉,除了数字和.
obj.value = obj.value.replace(/[^\d.]/g,"");
//必须保证第一个为数字而不是.
obj.value = obj.value.replace(/^\./g,"");
//保证只有出现一个.而没有多个.
obj.value = obj.value.replace(/\.{2,}/g,".");
//保证.只出现一次,而不能出现两次以上
obj.value = obj.value.replace(".","$#{1}quot;).replace(/\./g,"").replace("$#{1}quot;,".");
}
</script>
</head>
<body>
<!--把下面代码加到<body>与</body>之间-->
只能输入数字和小数点的文本框:<input id="input1" onkeyup="clearNoNum(this)">
</body>
</html>
报js错误,求个正确的能运行的。谢谢。最后93分了,群给你了
解决方案 »
- hibernate的数据库连接
- myeclipse6.0怎么配置jstl?
- 如何学好软件工程?
- java 文本比较类似 SVN代码比较的功能
- 程序安全性方面除了注意SQL注入还应该注意哪些方面?
- 关于IE进度条的问题
- 请问怎么取数据集ResultSet RS中的日期型字段,谢谢!
- JSP连接Oracle8.17(本地)不行,连接远程Oracle8.05就可以,为什么?
- 请教各位高手,如何用jsp调用doc文件直接修改
- Extjs 【简单问题】鼠标移出panel的时候关闭panel或则隐藏这个panel
- 如何用ajax,json实现发送xml到服务器端,再解析从服务器端返回的xml?
- xfire生成客户端调用的程序 报错 求解!
<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
只能输入数字和小数点的文本框:<input onkeyup="value=value.replace(/[^\d\.]/g,'')">
</body>
</html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
只能输入数字和小数点的文本框:<input onkeyup="value=value.replace(/[^\d]/g,'')">
</body>
</html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
只能输入数字和小数点的文本框:<input onkeyup="value=value.replace(/[^\d]/g,'')">
</body>
</html>
++