控制我的输入类型并验证其值在我的表单中是一个浮点数我在javascript中处理它是这样的:
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;
}
Run Code Online (Sandbox Code Playgroud)
但它仍然是假的,因为它不接受真正的浮动.因此,当输入类似'11,2'的值时,警报会被解除.
我想知道如何用javascript控制浮点值.谢谢.