Regular expression for validating date javascript

We have also checked the leap year factor for the month of February.We have used "/" and "-" character as a separator within the date format but you are free to change that separator the way you want.

I'm not going to show that here, but you can find a link to get started under References below. 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.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.If not, the input is compared to the regular expression.

You must have an account to comment. Please register or login here!