When we created something similar in the past, we allowed the user to enter a date in the text box in several ways:
- DDMMYYYY
- D / M / YYYY
- 0 (today)
When the form was submitted, we had a simple ASP function to convert DDMMYYYY to DD / MM / YYYY (the date string should be 8 characters, although since the assumption was 2 digits for DD, insert a separator, 2 for MM, etc.) and check that it is a valid date, and if formdate = 0 then formdate=now() rule.
You also need to add some JavaScript validation on the form. In the text box, add the onblur event to verify the same: either the entered 8 digits, or the valid date, or 0 - otherwise warn the user. (I would do it in jQuery if we reworked it today)
You can get useful information using Javascript "validation" to speed up data entry if you want, for example, if many dates entered are yesterday or tomorrow, allow -1 or +1, or data entry is always during the current month, but on another day, allow the user to simply enter the number - 15, and Javascript / jQuery converts the string to 03/15/2011.
source share