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.
In this case, we've created a stand-alone functions which will validate a date field: In each case the value passed to the function is the form field rather than the field value.
The Ajax Request class is a simple one we've created and use on a number of projects.
You can find the details in Web Services using XMLHttp Request (Ajax) and related articles. It doesn't allow a space after minutes and before the am/pm example: " am" will get an invalid time. I modified the reg to the following: re = /^(\d): (\d)(:00)?
I'm not going to show that here, but you can find a link to get started under References below. 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.We have also checked the leap year factor for the month of February.EDIT Note that the above regex is not correct (ie it can approve invalid dates). For instance, how do you handle leap years, different months having different number of possible days, etc. Use a library that can parse it, if it cant be parsed, its not a date time. I guess the brief answer is, don't use regex to validate date times.