gbvreddy
asked on
error handling
I have a form, in which a user enters data. One of the fields on the form is a date field. I want this to happen when a users clicks on "continue":
If the user entered an invalid date, for example the correct format is "12/12/2004". If he enters "12-12-2004" . Then I should highlight the text box for date.
Thanks,
Venkat
If the user entered an invalid date, for example the correct format is "12/12/2004". If he enters "12-12-2004" . Then I should highlight the text box for date.
Thanks,
Venkat
isValidDate will pass both of those, however you can put a date format in a registry key and then copare to that, or you can hard code it into your program though that sucks if you change your mind later on what you want to be accepted, if you use a key you can change it any time. then just focus back to text box when the form fails because of the date error.
like this
<body onload="document.forms['fo rmName'].e lements['e lementName '].focus() ">
where formNAme is the Name of the FORM :
<FORM name="formName" id="formName">
and elementName is the elementNAme :
<input type="text" name="elementName" id="elementName">
then pass the element name back from the validation code.
like this
<body onload="document.forms['fo
where formNAme is the Name of the FORM :
<FORM name="formName" id="formName">
and elementName is the elementNAme :
<input type="text" name="elementName" id="elementName">
then pass the element name back from the validation code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
How about using a calendar control like the DatePicker. Ensures user can't enter an invalid date and ensures no confusion over proper format.
mlmcc
mlmcc
ASKER
Thanks a lot everyone !
Venkat
Venkat
Private Sub Continue_Button_Click()
' Validate date field here
if not valid then
Datefield.setfocus
exit sub
else
' do whatever needs to be done with a valid date
end if
End Sub
Regards .. Alan