Program rule to check decimal places

Dear all,
Please, how do I set a program rule to check if the number entered exceeds 2 decimal places?

Thanks.
Best,
U’aa

1 Like

@Uaa

You should be able to use a d2:validatePattern function with a RegEx pattern to identify any number with 3 decimals or more.

For the regex, try something like
[0-9]+\.[0-9][0-9][0-9]
(you need two backslashes since one is the escape character that DHIS2 usually requires)
The regex should return true if the number has three decimals or more, but false if two or less

Regards
Calle

4 Likes