How to test for bad numbers using JavaScript?

Q

How to test for bad numbers using JavaScript?

✍: Guest

A

The global method, "isNaN()" can tell if a number has gone bad.
var temperature = parseFloat(myTemperatureWidget.value);
if(!isNaN(temperature)) {
alert("Please enter a valid temperature.");
}

2011-06-28, 2741👍, 0💬