I know this topic has been quite active in SO, but now I seem to have found something strange with input
fields with type="number"
and decimal numbers. My code is something like this:
function Sum(){
var f = document.myform;
var num1 = f.num1.value;
if (isNumber(num1)){
alert(parseFloat(num1));
}
}
function isNumber(n) {
return (!isNaN(parseFloat(n)) && isFinite(n) && n >= 0);
}
#num1 {
display:none;
}
<form name="myform" enctype="application/x-www-form-urlencoded" action="javascript:void(0);">
<input id="num1" type="number" value="1.5">
<input id="run_button" class="button" type="submit" onclick="Sum()"/>
</form>
Every time I put decimal numbers in number fields, I get this error, but if the numbers are without the dot, the error does not appear. You can test in test form.