<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="JavaScript">
function isshuzi(s)
{
var shuzi="0123456789";
var i;
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (shuzi.indexOf(c)<0)
{
alert("请输入数字");
}
}
}</script>
</head><body>
<form name="form1" method="post" action="">
  <input type="text" name="t1" onKeyDown="isshuzi(this.value)">
</form>
</body>
</html>