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?

Thanks

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:

Thanks

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:

Thanks

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.

Thanks!


@fernandoshake did it work? Thanks!