I have a function to make sure a user enters a number. How can I include a number and a comma and period if a user wants to enter a price such as: 9.90?

The line: if(charVal < "0" || charVal > "9" && charVal != "." && charVal != ",") still prevents a comma and period.

function isNumber2(inputStr, field)
{
for(var i=0; i<inputStr.length; i++)
{
var charVal = inputStr.substring(i, i+1);
if(charVal < "0" || charVal > "9" && charVal != "." && charVal != ",")
{
alert("Please make sure your " + field + " entry are numbers ., only");
return false;
}
}
return true;
}

Robert O.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to