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.
I believe the problem may be that it’s not considering
11,2to be a valid float, instead expecting something like11.2. Give the11.2a try and see if it works. Should that be the problem, I’m not sure if there’s some localization option that can be set, or if you need to manually swap the two before runningisNaN.Edit Ah, this webpage confirms it: