Help: Age validation

Hi all,

I have a tracked attribute age in years and I would like users to enter a number greater than zero and less than 100.

Can anyone help me?


1 Like

Hi @fernandoshake,

You’d need to create a program rule with the expression d2:hasValue(#{ageinyears}) > 0 && d2:hasValue(#{ageinyears}) < 100 and then the action is to show error.

You can watch the Program Rules session below to learn more about the program rules:

Good luck! :+1::+1:

Hi @Gassim,

The expression is showing the following error:


That’s because the A{Idade do participante} is TEXT so you need to change it to a number value probably a positive integer.

Hi @Gassim,

The attribute is not a TEXT. It is positive integer:


It’s working here:

If you please clear the browser cache, try in incognito and then see again if it’s working or not.

If it’s not working after clearing the cache and trying in incognito please share the configuration of the attribute and the variable as well as what DHIS2 version are you using.


@fernandoshake did it work? Thanks!