PDA

View Full Version : NaN how do I detect that?


Steven_Smith
12-06-2002, 12:35 AM
Hey People I am stuck and I am tired.

I have a calculator that I am doing.

but people might put in "text" not a number.

So when the script runs, it puts NaN in the result area.

if (ans=="NaN"){alert("Hey Stupid, put in a number");}

but that doesn't work.

how can I detect a 'NaN'

Any ideas.

whammy
12-06-2002, 12:43 AM
if (isNan(yournumbervariable)) {
// do something since it's "Not a Number"
}

// or

if (!isNaN(yournumbervariable) {
// do something here since it is a number!
}


:D