Check if a string is a Not-A-Number with isNaN function in JavaScript
Description
The following code shows how to check if a string is a Not-A-Number with isNaN function.
Example
console.log(isNaN("10"));
//false - can be converted to number 10
/*from w ww.j a v a 2 s . com*/
var entry1 = "123.123";
var number = new Number();
number = Number(entry1);
if (isNaN(number)){
console.log("You did not enter a valid number.");
}else{
console.log(number.valueOf());
}
The code above generates the following result.