Survey 123 phone number constraint

1911
6
12-14-2022 10:09 AM
Labels (1)
fatihsonmez1
New Contributor II

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
New Contributor III

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
New Contributor III

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
New Contributor II
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
New Contributor III

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
New Contributor II

Thank you so much. I think I understand. 

I try,

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

 

 

0 Kudos
AmeWunderle
New Contributor III

Looks good to me. Test it out.

 

0 Kudos