没有问题检测数字也不用这么麻烦,用if (!isNaN(form.input1.value)) alert("这里必须填写数字!");或者
<input type=text onkeypress="return checkKeyPress()">
<script>
function checkKeyPress()
{
if ((window.event.keyCode<48&&window.event.keyCode!=13) || window.event.keyCode>57)
   window.event.keyCode=0;
return true;}</script>