Including 0 in phone number as first digit

Dear Kobo community, I am trying to include 0 as the first digit counted in an 8-digit restricted phone number but it is not working. I am using regex(.,‘^[00-99]{8}$’) constraint as was present in the Kobotoolbox community suggestion. What should I do?

phone.xlsx (40.6 KB)

@myriamdagher1, you could do it as outlined in the image shared below:

In the survey tab of your XLSForm:

Data entry screen as seen in Enketo:

Image 2

Data entry screen as seen in Enketo:

Image 3

Reference XLSForm:

Phone Number With Leading 0.xlsx (15.9 KB)

We have some numbers that starts with another digit other than 0 (e.g., 76200888). So in that case this constraint is not working nor in the case that I tried before. Can you suggest what to do?

@myriamdagher1, could you list out the possible digits? Maybe I could then have a look at the regex code again.

@Kal_Lam possible digits are for example: 03776655 ; 71345678 ; 81345678
What do you recommend?

@myriamdagher1, this code as shown in the image should solve your issue:

Please note that it accepts 0, 7 and 8 as initial numbers.

Reference XLSForm:

Phone Number With Leading 0.xlsx (15.9 KB)

Thank you so much @Kal_Lam ! Since other possible phone numbers can start with any digit I’ve tried this code and it worked: regex(.,‘^[0|1|2|3|4|5|6|7|8|9]{1}[0-9]{7}$’)

Do you see this ok?

Phone Number With Leading 0.xlsx (16.0 KB)

@myriamdagher1, if any numbers could start, you could simply use the following regex code:

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

1 Like

It worked thank you! @Kal_Lam

1 Like

@myriamdagher1, :clap: :heart: :partying_face: