Validation formula for date validation in forms

I am looking for the right formula I can insert to the Validation part of a form, which would give an error message in case the typed date format is incorrect.

First part:
I want the date format as DD-MM-YYYY, so 14-04-2025. In any other format it should give an error message reminding the users for the correct format.

I created a text column but I cannot find the formula where I can compare the typed format and in case it gives a false result.

Second part:
On the top of that is it possible to add to this formula that the first part (the first two digits can be between 01-31 only, the two digit after “-” can be only between 01-12, and the last for digit after “-” can be only between 1920-2025?

I would be grateful if someone could point to the good direction.

Thanks a lot!

hi, u can use regexMatch :

^(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[0-2])-(199\d|20\d{2}|21\d{2})$
3 Likes

Thanks for the quick reaction!

Is this the correct syntax for the formula?

RegexMatch(CurrentValue,“^(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[0-2])-(199\d|20\d{2}|21\d{2})$”)

I guess I just have to learn the structure of RegexMatch so I can understand it better, how to set it up. :slight_smile:

got it working thanks!

This was the correct syntax:
RegexMatch(CurrentValue,“(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[0-2])-(19\d{2}|20\d{2}|21\d{2})”)

Considering that either the datepicker feature or the select list feature is very far from user friendly on smart phones (android), I find this solution the best and most user friendly when creating a form with requesting to input a date (e.g. birthdate).

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.