Basic JavaScript Question:
How to test for bad numbers using JavaScript?
Answer:
The global method, "isNaN()" can tell us about value if a number has gone bad in JavaScript.
var temperature = parseFloat(myTemperatureWidget.value);
if(!isNaN(temperature)) {
alert("Please enter a valid temperature.");
}
var temperature = parseFloat(myTemperatureWidget.value);
if(!isNaN(temperature)) {
alert("Please enter a valid temperature.");
}
Previous Question | Next Question |
How to convert numbers to strings using JavaScript? | What's Math Constants and Functions using JavaScript? |