The year limitation would be used if you were asking for a date of birth or date of some recent event.If you're setting up a calendar of future events you would check that the year is the current year or greater.The goal of is to provide a cross framework and cross language way of validating data.
In this tutorial, we discussed how you can perform Java Script date validation in 1. dd, mm and yyyy) and check whether dd is a valid date, mm is a valid month or yyyy is a valid year.
In this example, the date fields will only accept input that matches the pattern 'dd/mm/yyyy' (this could just as easily be changed to 'yyyy-mm-dd' or 'mm/dd/yyyy').
The time field will allow input starting with 'hh:mm' following by an optional 'am' or 'pm'. The code behind the form is as follows: For each field in the form (first the dates, then the time field), a check is made as to whether the input is blank.
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.