Survey 123 phone number constraint

2549
6
12-14-2022 10:09 AM
Labels (1)
fatihsonmez1
Emerging Contributor

How can I write a phone number without leading zeros, restricting it to 10 digits, are there any enhancement plans or constraint field code

For example: 5555555555

 

 

 

 

 

 

 

0 Kudos
6 Replies
AmeWunderle
Regular Contributor

You can add a constraint to the field. An example that esri gives is setting the constraint column to the following for phone numbers:

string-length(.)>=8 and string-length(.)<=12

You can also use a regex expression. Here's the suggestion from esri for emails for example (it won't let me paste it directly here so here's a screenshot): 

AmeWunderle_0-1671043406264.png

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet is a link to more information on how to formulate regex expressions

0 Kudos
AmeWunderle
Regular Contributor

You can also try for the phone number:  regex([0-9]{10}) which will limit it to 10 digits not just the string length

fatihsonmez1
Emerging Contributor
I tried but I get an error. I need to write this code in the constraint section, right? By the way, the question is in text format.
0 Kudos
AmeWunderle
Regular Contributor

sorry, you will need to change the syntax a little. The regular expression (regex) should include a (.,'()') for survey123 constraint so:

regex(.,'^([0-9]{3})(-)([0-9]{3})(-)([0-9]{4})$') if you want dashes

regex(.,'^([0-9]{10})$') if you don't

fatihsonmez1
Emerging Contributor

Thank you so much. I think I understand. 

I try,

regex(.,'^(?!0)[0-9]{10}$')  if you correct syntax?

 

 

0 Kudos
AmeWunderle
Regular Contributor

Looks good to me. Test it out.

 

0 Kudos