Web Tools Table Maker3schools TranslateImage CompressorFavicon Icon GeneratorCrop & Resize Image
Apu
Apu October 06, 2022 › #Function #HowTo

Write a JavaScript function to validate whether a given value is a number or not

In this article, we will write a JavaScript function to validate whether a given value is a number or not.

To validate a value, is a number or not , we will use the isNaN() method.

Demo : check if character is a number. #
function myFunction(e){
  if(!isNaN(e)){
    return 'Yes, this is a number'
  }
  else{
    return 'No, this is not a number'
  }
}
Try it Yourself »

The isNaN() method returns true if the value is not a number. If the value is a number , it returns false.

Example : isNaN() method. # Try it Yourself »
save
listen
AI Answer
Write Your Answer
loading
back
View All