August 1999
Intermediate to advanced
1488 pages
72h 53m
English
isNaN(variable)
The isNaN() function is used to determine whether or not variable is a valid number.
Listing 6.148, shows how the isNaN() function can be used to check user input.
<html> <body> <script lanuguage="JavaScript"> <!–– Hide function checkNum(){ var n = document.form1.text1.value; if(isNaN(n) == true){ alert("Your entry is not a number"); } } // End Hide –– > </script> <form name="form1"> Enter a number or character into the text box and then click the check value button to verify if the input is a number. <br><br> <input type="text" name="text1" size=3> <br><br> <input type="button" value="Check ... |
Read now
Unlock full access