Link to home
Start Free TrialLog in
Avatar of gbvreddy
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
Avatar of ADSaunders
ADSaunders

Hi gbvreddy,

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
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['formName'].elements['elementName'].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.
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike McCracken
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
Avatar of gbvreddy

ASKER

Thanks a lot everyone !

Venkat