if(parseInt(text.value)!=text.value)
  alert("error")

解决方案 »

  1.   

    <input type=text id=tid><input type=button value=Check onclick=checknum()>
    <script>
    function checknum()
    {
        var i=tid.value;
        if((i.length==parseInt(i).length)&&isNaN(i)==false)
            {
            alert("Is Integer!")
            }
    }
    </script>
      

  2.   

    <script language="JavaScript">
    function checknum()
    {
       if(parseInt(form1.t1.value)!=form1.t1.value)
      alert("error")
    }
          </script>
    <form method="POST" name="form1" action="--WEBBOT-SELF--">
        <input type="text" name="t1" size="20"><br>
        <input type="button" value="Check" onclick="checknum()">
        </form>