Program Rule Validation Issue on Android for Two-Digit Code

Hi everyone,

I’m encountering an issue with program rule validation in DHIS2 Android v2.9.1. I’m trying to validate a field ‘Sup - code superviseur’ to ensure it contains exactly two digits. The following rule works correctly on the web version:

!d2:validatePattern(#{Sup - code superviseur}, '^[0-9]{2}$')

However, it does not work on the Android version. I’ve tried other approaches using d2:length and d2:substring, but I haven’t been able to get it working on Android.

Has anyone experienced a similar issue, or does anyone have suggestions on how to implement this validation for the Android app?

Thank you for your help!

Hi @elmoujarrade

You can use the field mask and add a description to the data element or attribute so the user knows what is expected in the field.

image
image

Let me know if this helps.

3 Likes

Hi @nancyesp

Thank you so much for your suggestion! I tested the field mask as you recommended, and it works perfectly. The issue is now resolved.

I appreciate your help and the support from the community.

Best regards,

2 Likes