Hi All, I have to do one validation in javascript. I have text box into which user should not allow to enter value which is more that 5.00 means user can enter value which is less than 5.00. so please suggest such validation in javascript
A:
var textboxObj = document.getElementById("textbox");
if(parseFloat(textboxObj.value) <= 5){ // to ensure user has entered only numbers
alert("success");
}else {
alert("Invalid input");
}
Chinmayee
2010-10-18 10:20:08
simple approach is the best, but you'll want to check for `NaN` (Not A Number) as well, otherwise any non-numeric input may register as success.
Spudley
2010-10-18 10:31:15