controling a float value with javascript
- by kawtousse
Hi,
to control my input type and verify that its value is pretty a float in my form i deal with it in javascript like that:
function verifierNombre () {
var champ=document.getElementById("nperformed");
var str = champ.value;
if(str.value==' '){champ.focus();}
if (isNaN(str)) {
alert("Invalid Valid! the field must be a number");
champ.focus();
return false;
}
return true;
}
but it still false because it doesn't accept really floats.
so when entering a value like '11,2' the alert is declenched.
I want to know how can I control float values with javascript.
thanks.