Each of these values is then tested against an allowed range (days: 1 - 31; months: 1 - 12; years: 1902 - 2019; and so on).This script only confirms that the input format is correct and that each individual value falls within its allowed range.
If you're setting up a calendar of future events you would check that the year is the current year or greater.
Its good practice to validate form date values using client side Java Script validation along with your programming language validation.
The following example shows how you can do this for the mm/dd/yyyy format.
The code behind the form now is as follows: If you're not already familiar with regular expressions, then this might be getting a bit complicated.
Basically, for each of the regular expression tests, an array is returned holding each component of the pattern that we've matched.