<input value=123 id=iecn><input type=button value=test onclick=checkNum(iecn.value)>
<script language=javascript>
function checkNum(str)
{
  var re=/^\d+$/;
  if(re.test(str))
    alert("正确");
  else
    alert("错误")
}
</script>

解决方案 »

  1.   

    function splitNum(s)
    {
      s += "";
      if (!/^(\+|-)?\d+(\.\d+)?$/.test(s)){
        alert("不是数字"); 
        return false;
      }
    }
      

  2.   

    Description
    Determines whether a value is the reserved value NaN (not a number). 
    Syntax
    isNaN(numvalue) 
    The numvalue argument is the value to be tested against NaN. Res
    The isNaN function returns true if the value is NaN, and false otherwise. You typically use this function to test return values from the parseInt and parseFloat methods. 
    Alternatively, a variable could be compared to itself. If it compares as unequal, it is NaN. This is because NaN is the only value that is not equal to itself. 
      

  3.   

    function IsNum(s)
    {
      if (/^\d+(\.\d+)?$/.test(s)){
        return true;
      }
      else {
        return false;
      }
    }
      

  4.   

    function isNumeric(exp)
    {
        return !isNaN(exp);
    }