Simple Date Validation and Year Completion in JavaScript

Dates in Web forms drive me crazy! On some sites, you must enter a date in a very particular
format. On other sites, you must have 4
digit years, but 2 digit years on other sites. For this reason, we have decided to package and release a simple set of JavaScript routines that:

  • Allow users to enter dates in many different formats
  • Permits 1, 2, and 4 digit years
  • Converts years into a specified range (past, future, a
    50 year window in the past or future, or a custom range)
  • Rewrites the date into a standard M/D/YYYY format

To use it, add an appropriate call to an onChange event in
the INPUT HTML tag. For example: <INPUT name=”mydate”
onChange=”checkSPLITDATE(this)”> will create an input box that will
automatically format dates into a date within a range 50 years in the past to
50 years in the future.

Please get it at