Are there any enhancement plans or constraint field code (similar code for valid emails via Connect: regex(.,'^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$')) so users can only enter a xxx-xxx-xxxx value in a field for a phone number?
Solved! Go to Solution.
Hi Carl,
What you're probably looking for is actually the Input Mask capability - Esri custom columns—Survey123 for ArcGIS | ArcGIS . For example, a North American phone number (+1-###-###-####) can be expressed as D99-999-9999 (the D at the beginning is 1-9, the 9 is 0-9); technically the first digit can't be 1, but for your purposes, it will do. Note that this pattern outside North America can change from country to country, as each country has their own pattern for creating phone numbers.
If you do want to implement it via a constraint check, it is fairly straight forward. The regex function
regex(., '[2-9]\d{2}-\d{3}-\d{4}')
accomplishes that (area codes don't begin with 1)
You will have to wait until arcmap catchs up with Python, underscores are not accepted and supported in numeric literals
PEP 515 -- Underscores in Numeric Literals | Python.org
which basically means your phone number will actually be treated as a number
Hi Carl,
What you're probably looking for is actually the Input Mask capability - Esri custom columns—Survey123 for ArcGIS | ArcGIS . For example, a North American phone number (+1-###-###-####) can be expressed as D99-999-9999 (the D at the beginning is 1-9, the 9 is 0-9); technically the first digit can't be 1, but for your purposes, it will do. Note that this pattern outside North America can change from country to country, as each country has their own pattern for creating phone numbers.
If you do want to implement it via a constraint check, it is fairly straight forward. The regex function
regex(., '[2-9]\d{2}-\d{3}-\d{4}')
accomplishes that (area codes don't begin with 1)
That worked, thanks again for the quick help.