Sitecore Form Regex Validation to check if date is in mm/dd/yyyy format


This regex pattern checks for dates in the mm/dd/yyyy format and also takes leap years into account. Here’s a breakdown of the regex:

(0[1-9]|1[0-2]): Matches months from 01 to 12.
(0[1-9]|1\d|2[0-8]): Matches days from 01 to 28.
(19\d{2}|20\d{2}): Matches years in the range 1900 to 2099.
(0[13-9]|1[0-2])/(29|30)/(19\d{2}|20\d{2}): Matches months with 29 or 30 days and validates leap years.
(0[13578]|1[02])/31/(19\d{2}|20\d{2}): Matches months with 31 days.
Leap year validation: It checks for leap years by considering both divisible by 4 (except for years divisible by 100 but not by 400) and not divisible by 100 but divisible by 4.

Note: I have not tested this on my instance.

Read more here: Source link