Regular expression for validating date javascript

The year limitation would be used if you were asking for a date of birth or date of some recent event.

: # group without capture # that match 31st of month 1,3,5,7,8,10,12 (? # number 0 optionnal [13578] # one digit either 1,3,5,7 or 8 ) # end group | # alternative (1[02]) # 1 followed by 0,1 or 2 ) # end group - # dash (19|20)?

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.

For example, when the date is checked, the return value, , is an array with elements 1 through 3 containing the day, month and year components of the input string.

For the time check, the array returned includes the hour (pos 1), minutes (pos 2) and, optionally, the am/pm string (pos 3).

Search for regular expression for validating date javascript:

regular expression for validating date javascript-37

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “regular expression for validating date javascript”

  1. STOP wasting time with online dating sites such as match.com, eharmony.com, ZOOSK.com, itsjustlunch.com, christianmingle.com, ourtime.com, and others.

  2. Creating an atmosphere that is at once casual and comfortable. For those that prefer the same simplified experience in matchmaking we offer our 'Date Nights' free of contracts or commitments.