Phone Number Constraint does not work

Hi, please help.

My constraint code does not seem to work, I want to make limit to my form where people need to submit their phone number, that can range to 10-12 digits.

This is what i put in the constraint column, regex(.,β€˜[1]{10,11,12}$’)

Please kindly help

Thank youuuu :slight_smile:


  1. 0-9 β†©οΈŽ

@wiydiy, this screenshot shared below should help you solve your issue:

In the survey tab of your XLSForm:

Data entry screen as seen in Enketo (when the input digit is less than 10 digits)

Data entry screen as seen in Enketo (when the input digit is more than 12 digits)

Data entry screen as seen in Enketo (when the input digit is in the range of 10-12 digits)

Reference XLSForm:

Phone Number (10-12 digit).xlsx (9.3 KB)

1 Like

thanks a lot :slight_smile:

2 Likes

Hi Kal,

turns out the code does not work for a 10 digits phone number that starts with zero, but it works with number other than 0,

it works just fine for 11 and 12 phone number.

Please help.

@wiydiy, if you wish to have the first number as zero, try using this regex code:

regex(., '^0[0-9]{9}$')

hi Kal, your code doesn’t seem to work

your old code works better but as i said, it produces error on the 10 digit phone number that starts with 0.

please kindly help :slight_smile:

@wiydiy, the code shared above works for a 10-digit phone number. If you need 9-digit, you will need to adjust it accordingly. Try using the following:

regex(., '^0[0-9]{8}$')

Even when i put in 10 digits, the error message still shows up like this:

And my actual validation criteria is the phone number always starts with 0 and consist of 10-13 digits

please kindly help

@wiydiy, could you share with us the regex code you have been using? What is the question type you have used for that question?

Since i want the phone number always starts with 0 (zero), and has range of 10-13 number, this is my regex code:

regex(., β€˜^0[0-9]{9,12}$’) and the question type is integer.

the error now persists

exhibit 1 (10 digits phone number):

exhibit 2 (11 digits phone number):

exhibit 3 (12 digits phone number):

please kindly helpppp.. thank youuu

Wait,

i solved this issue by using this regex:

regex(., β€˜^+?0[0-9]{9,12}$’) and change the question type to text.

Thank you.

1 Like

@wiydiy, :tada: