Validate pattern for date range


I have a TEA called Day of birth which needs to be validated so that only two digits can be entered in this field, and that these two digits need to be between 01-31. I’ve inherited a PR which does the first part:

(!d2:validatePattern(A{REA- Day of birth},’^\d{2}$’)) && (A{REA- Day of birth} != ‘’)

PR Action: Show warning: Day of birth must be a two digit number for example 04 or 17

I can’t figure out how to add to this PR to validate the second requirement that the two digits need to be between 01-31. Any tips on how to achieve this would be much appreciated!



Hi @monika .

I have created a test program in Play 2.35.1 () which should be available until tonight if you want to test it. It is called PR Validation and works with what you are looking for. I didn’t invest time in changing the attribute names so your rules is applied on the attribute first name and not in the age.

Your rule should be as follows (I changed 01 to 04 so you see it fails on 03)

However, I don’t think this is very user friendly as you are forcing the users to put manually something like 03 instead of 3 which might confuse users. Also, you may want to use the attribute type “Age” which provides an input for this:




1 Like

Hi @jaime.bosque,

The PR you proposed works exactly as I hoped and I was able to replicate on our instance as well - thanks for this!

I take your point about the Age attribute. The issue with this is that we are literally only interested in Day of Birth, and want to discourage any users from entering the full date of birth, for data protection reasons. But that tip will come in handy for our other program :slight_smile:

Thanks again!


1 Like