判断输入信息为数值类型
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script>
function isInt(s)
{
if(s.value!="")
{
var p=/^[0-9]{1,20}$/;
if (!p.exec(s.value))
{
alert("类型不对,必须填写数值类型!");
s.value="";
s.focus();
return;
}
}
}
</script>
</HEAD>
<BODY>
<input type=text id="txtName" name="txtName" onfocusout="isInt(this)">
</BODY>
</HTML>