这个是限制用户输入为5位整数加2位小数,测试通过了
<html>
<script language=javascript>
function a123(e)
{
var a=e.value;
re=/^\d{5}\.\d{2}$/g
if(a.match(re)==null)
{
alert("错误")
}
}
</script>
<body>
just a test!
<input type="text" onchange=a123(this)>
</body>
</html>
<html>
<script language=javascript>
function a123(e)
{
var a=e.value;
re=/^\d{5}\.\d{2}$/g
if(a.match(re)==null)
{
alert("错误")
}
}
</script>
<body>
just a test!
<input type="text" onchange=a123(this)>
</body>
</html>
re=/^\d{5}\.\d{2}$/g
if(!re.test(a))
{
alert("错误")
}