
October 31st, 2007, 05:27 PM
|
|
Registered User
|
|
Join Date: Oct 2007
Posts: 1
Time spent in forums: 14 m 59 sec
Reputation Power: 0
|
|
|
Other - Validating date entry onkeypress
Hi,
I want to validate a date entry onkeypress in 3 autotab-ed text boxes with the format mm/dd/yyyy.
I've written this:
Code:
<script>
function autotab(current,to){
if (current.getAttribute &&
current.value.length==current.getAttribute("maxlength")) {
to.focus()
}
}
</script>
<b>Enter date(mm/dd/ccyy ex (10/28/1955):</b>
<form name="date">
<input type="text" name="mm"
size=3 onkeypress="return onKeyPressBlockInvalid(event);" onKeyup="autotab(this, document.date.dd)" maxlength=2>/
<input type="text" name="dd"
size=3 onKeyup="autotab(this, document.date.yyyy)" maxlength=2>/
<input type="text" name="yyyy" size=5 maxlength=4>
Can you please let me know how can I do this? Regex?
I can see that the 1st position of the 1st text box can be (0,1,2-9) and the 2nd position (1-9,0-2,X), 1st position of the 2nd text box can be (0,1,2,3,4-9) and the 2nd position (1-9,0-9,0-9,0-1,X) respectively and the 4 digits in the 3rd text box can be anything.
Appreciate your help.
Angkar
|