-3
function processForm() {

    var temperature = document.tempForm.temp.value;

}

According to designed button,I want to take temperature value from text field and to convert numeric value then store it in variable "temperature" that I defined.

JavaScript has a built-in function called Number(). It converts the value in parentheses to a number that can be used in calculations. If it is not a number, it will return NaN (Not a Number).

How can I do this?

4

1 回答 1

1
temperature = temperature *1;

or

temperature = +temperature;

temperature will be NaN if it is not a number

于 2013-01-24T21:50:44.137 回答