isNaN Method
Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). isNaN(numValue) The required numValue 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.

解决方案 »

  1.   

    <Script Language="JavaScript">
    <!--
    var strValue="1";
    iTest=strValue*0;
    if(iTest!=0) 
    alert("字符型");
    else
    alert("数值型");
     -->
    </Script>
      

  2.   

    书上的例子.vbscript
    r = 53                 
    k = IsNumeric(r)    ' 返回 True。ar = "459.95"              
    ck = IsNumeric(ar)    ' 返回True。
      

  3.   

    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE></TITLE>
    </HEAD>
    <BODY>
    <form name=myform><input type=text name=text>
    <input value=check type=button onclick=chk()></form>
    <script language=javascript>
    function chk()
    {
    if (isNaN(document.myform.text.value)==false) alert("数字")
    else alert("非数字")
    }
    </script>
    </BODY>
    </HTML>