F
fixertool
I have a textbox field with numeric validation using a function with
onkeypress event
<input type="text" name="xxx" id="xxx" size="8" maxlength="7"
onkeypress="IsNumeric(this);" />
The function is very simple and known (and it works fine):
function IsNumeric(e)
{
if (event.keyCode < 48 || event.keyCode > 57)
{
alert("Only Numbers, please.");
return false;
}
}
Let's say I try to input 12q. Well, when I press 'q' key, the alert
obviously jumps. Then I click alert's 'OK' button, obviously too.
The focus goes to the field again, and the field value now is 12q.
But I want the field value turns 12. That is, without the last non-
numeric key value pressed. Am I clear enough?
Thanks in advance
onkeypress event
<input type="text" name="xxx" id="xxx" size="8" maxlength="7"
onkeypress="IsNumeric(this);" />
The function is very simple and known (and it works fine):
function IsNumeric(e)
{
if (event.keyCode < 48 || event.keyCode > 57)
{
alert("Only Numbers, please.");
return false;
}
}
Let's say I try to input 12q. Well, when I press 'q' key, the alert
obviously jumps. Then I click alert's 'OK' button, obviously too.
The focus goes to the field again, and the field value now is 12q.
But I want the field value turns 12. That is, without the last non-
numeric key value pressed. Am I clear enough?
Thanks in advance