<input onKeyPress = "return (event.keyCode < 48 || event.keyCode > 57) ">

解决方案 »

  1.   

    function isdigit(theField) {
        inStr = theField.value;
        inLen = inStr.length;    for(var i=0; i<inLen; i++) {
             var ch = inStr.substring(i,i+1)
                if (ch < "0" || "9" < ch) {
                    return false;
                 }
            }
            return true;
    }用的时候:
    if(isdigit(form1.xx)==true)
    {  alert("不可以是数字!");
              return false;
    }
      

  2.   

    用isNaN(value),如果value不是数字返回真。(is not a number为true)
      

  3.   

    同意xding(小丁),用isNaN,或者用正则表达式