Validating date

In this example, employees will fill in a Vacation Request Form for the year 2017.

validating date-36

To download the sample file, click here: Data Validation for Dates The zipped file is in xlsx format, and does not contain any macros.

Description: This script validates a date field to ensure it's in the format mm/dd/yyyy.

The expressions use a pre-defined class is returned which enables the form to be submitted.

This routine DOES NOT check that the date or time input values are valid, just that they match the required format (d/m/y and h:m). Once you're in control of the input format, it's a lot easier to check that the values are actually valid.

The function has been improved now so that the day, month and year values are checked to ensure that they're in the right ball-bark (ie. Also the year must be between 1902 and the current year.

The year limitation would be used if you were asking for a date of birth or date of some recent event.

“29/a/2008”, “a/02/2008” – month is invalid, day is invalid 6.

“30/2/2008”, “31/02/2008” – leap year in February has 29 days only 5.

“29/2/2007”, “29/02/2007” – 2007 is not leap year, only has 28 days 4.

“1/13/2010”, “01/01/1820” – month is out of range [1-12], year is out of range [1900-2999] 3.

[1-9] # 01-09 or 1-9 | # .[12][0-9] # 10-19 or 20-29 | # .3[01] # 30, 31 ) #end of group #1 / # follow by a "/" ( # start of group #2 0?