JavaScript Function isNaN

24th December 2007

Small JavaScript function to check if a variable is a number.

  1. function checkValue(value){
  2.   if(isNaN(value)){
  3.     return false;
  4.   }else{
  5.     return true;
  6.   }
  7. }

Use this in your form validation if you are checking to see that a user has entered a number.

Add new comment

The content of this field is kept private and will not be shown publicly.