JohannIcon
Programmer
Hi All,
I am trying to check wether the user inputs a correct decimal number. The number must be smaller than 1 but bigger than 0. In other words, the user must input numbers like 0.01 or 0.712 for the number field to be correct. I am doing the following validation, however it is not working:-
function isNumber(inputVal)
{
inputStr = inputVal.toString()
for (var i = 0; i <inputStr.length; i++)
{
var oneChar = inputStr.charAt(i)
if (oneChar < "0" || oneChar > "1"
{
alert("Numeric Field Here. You must input a number, like 0.712"
return false
}
}
return true
}
What am I missing?
I am trying to check wether the user inputs a correct decimal number. The number must be smaller than 1 but bigger than 0. In other words, the user must input numbers like 0.01 or 0.712 for the number field to be correct. I am doing the following validation, however it is not working:-
function isNumber(inputVal)
{
inputStr = inputVal.toString()
for (var i = 0; i <inputStr.length; i++)
{
var oneChar = inputStr.charAt(i)
if (oneChar < "0" || oneChar > "1"
{
alert("Numeric Field Here. You must input a number, like 0.712"
return false
}
}
return true
}
What am I missing?