NaN is returned when a text field value in not a number. But to detect it, you can't write an if condition that variable x is equals to NaN because NaN is not equal to itself, so what you going to use is a an universal function.
Javascript well, have a solution for everything and this one too. Javascript have an universal function that isNan() which returns the value in the form of boolean. You check weather the return value is true or false and add your condition according to that.
But yes with this universal function we are using if condition.
var x=document.getElementById('foo').value;
if(isNaN(x)==true){
// Do Something
}
Post A Comment:
0 comments: