I would like to create custom validation for us phone numbers | XM Community
Solved

I would like to create custom validation for us phone numbers

  • 22 March 2018
  • 3 replies
  • 50 views

Badge +6
I would like to create custom validation so that respondents have to enter their phone number in the following fomat: (xxx)xxx-xxxx. I have tried using a custom validation with a regex statement, but it doesn't seem to work. Am I missing something? Thanks!
icon

Best answer by TomG 22 March 2018, 22:27

View original

3 replies

Userlevel 4
Badge +3
For sure! What Regex statement did you use? @TomG had a cool library that he uses in Javascript if you're able to use that. It's called Cleave.js. If not, we can get you the right Regex String!
Userlevel 7
Badge +27
If you want to go the custom validation route, here is a simple regex string (doesn't do any checking for valid area code or anything): `^\\([0-9]{3}\\)[0-9]{3}\\-[0-9]{4}$`
Badge +6
Thanks to both of you! I was using something similar, but the string that TomG provided works perfectly! Yay!

Leave a Reply