<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>3位小数和整数</title>
<script language="javascript">
function Check(reg,str)
{
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>3位小数和整数</title>
<script language="javascript">
function Check(reg,str)
{
if( reg.test(str))
{
alert("right");
return true;
}
return false;
}
// 数字
function CheckNumber(s)
{
var reg = /^[0-9]+\.?[0-9]{0,3}$/;
return Check(reg,s);
}
</script>
</head>
<body>
<form action="" method="post" name="form1">
<input name="a" type="text" />
<input name="" type="button" onclick="CheckNumber(document.form1.a.value);"/>
</form></body>
</html>