Checking date format

Some­times you have to deal with an Infopath textfield to col­lect a date. Then it would be use­full to check if the date that is entered is a valid one.

This solu­tion is not the per­fect one, but it fil­ters out most of the wrong answers and typo’s.

Click on “Val­i­da­tion” and add a new val­i­da­tion.

Enter this pat­tern in the pat­tern field. Make sure you select “does not com­pare to”

(([0–9])|([0–2][0–9])|(3[0–1]))\-(([1–9])|(0[1–9])|(1[0–2]))\-(([0–9][0–9])|([1–2][0,9][0–9][0–9]))
This checks for a euro­pean date (dd-mm-yyyy and d‑m-yy or any com­bi­na­tion)
An eng­lish ver­sion (MM/DD/YYYY) would be some­thing like this: (([1–9])|(0[1–9])|(1[0–2]))\/(([0–9])|([0–2][0–9])|(3[0–1]))\/(([0–9][0–9])|([1–2][0,9][0–9][0–9]))