<input type=3D"textbox" onBlur=3D"checkDate(this, strSubmitButtonID)" />
function checkDate(textBox, strSubmitButtonID){
if(textBox.value.search(/^\d{2}[-]\d{2}[-]\d{4}$/) !=3D -1){
// The textBox's value is ok
document.getElementById("strSubmitButtonID").focus();
}
}
/Robert
-----Original Message-----
From: Paulo Fernandes [mailto:paulofernandes@c...]
Sent: den 19 mars 2003 09:03
To: JavaScript HowTo
Subject: [javascript_howto] RE: Text box and date
Thanks, Robert.
I have a form with n text boxes, each one having its own submit button.
Can you teach me how to put this in a function and use it on the on exit
event of the text box? If date format is correct, the corresponding
submit button would be enabled.
The thing is that I can do this in ASP, but I wanted to avoid another
roundtrip to the server just to validate a date !!!!
Thanks in advance!
PauloF
-----Original Message-----
From: Robert Nyman [mailto:robert.nyman@c...]
Sent: quarta-feira, 12 de Fevereiro de 2003 7:53
To: JavaScript HowTo
Subject: [javascript_howto] RE: Text box and date
Use a regular expression:
if(textBox.value.search(/^\d{2}[-]\d{2}[-]\d{4}$/) !=3D -1){
// The textBox's value is ok
}
/Robert
-----Original Message-----
From: Paulo Fernandes [mailto:paulofernandes@c...]
Sent: den 11 februari 2003 22:00
To: JavaScript HowTo
Subject: [javascript_howto] Text box and date
I need to validate a text box in a form on the submit event.
It has to have the following format: "dd-mm-yyyy"
I know how to do this using ASP but I wanted to do it client-side...
Can anyone help me with a code example?
Thanks !
PauloF