controling a float value with javascript
Posted
by kawtousse
on Stack Overflow
See other posts from Stack Overflow
or by kawtousse
Published on 2010-05-20T16:22:52Z
Indexed on
2010/05/20
17:30 UTC
Read the original article
Hit count: 178
JavaScript
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.
© Stack Overflow or respective owner