field value AFTER numeric validation
- From: fixertool <replyfixer@xxxxxxxxx>
- Date: Fri, 30 May 2008 17:33:32 -0700 (PDT)
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
.
- Follow-Ups:
- Re: field value AFTER numeric validation
- From: Thomas 'PointedEars' Lahn
- Re: field value AFTER numeric validation
- From: Evertjan.
- Re: field value AFTER numeric validation
- From: SAM
- Re: field value AFTER numeric validation
- Prev by Date: Re: Local storage question
- Next by Date: Re: Array manipulation question
- Previous by thread: FAQ Topic - Which newsgroups deal with javascript? (2008-05-31)
- Next by thread: Re: field value AFTER numeric validation
- Index(es):