This is my code
else if(form.txtPrice.IsNumber){
alert("Price must be number") form.txtPrice.focus();
return false;
I can not check validation must be number in Javascript, everybody help me please, thank you so much!
This is my code
else if(form.txtPrice.IsNumber){
alert("Price must be number") form.txtPrice.focus();
return false;
I can not check validation must be number in Javascript, everybody help me please, thank you so much!
Use isNaN(value)
.
This returns true
if the value is not a number.
If the value is a number, will return false
.
Using only isNaN
is risky, it has some big inconvenient; These strings will be considered valid numbers:
you could do more:
function isNumber(input) {
return typeof input === "number" && !isNaN(input);
}
note that you have to parse if before if you have a string (parseInt/parseFloat)