Numeric Testing
Join the Discussion
There are a number of different ways to test if a variable contains a numeric value but the simplest way is to use parseInt if the field needs to be a whole number and parseFloat if the number can have decimal places.
The code to perform these tests looks like this:
alert(mynum + ' is not a whole number');
if (mynum == parseFloat(mynum))
alert(mynum + ' is numeric');

