Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
197
rated 0 times [  199] [ 2]  / answers: 1 / hits: 24248  / 14 Years ago, wed, november 10, 2010, 12:00:00

The following regular expression isn't working for international phone numbers that can allow up to 15 digits:



^[a-zA-Z0-9-().s]{10,15}$


What needs to be adjusted?


More From » regex

 Answers
5

Try adding a backslash:



var unrealisticPhoneNumberRegex = /^[a-zA-Z0-9-().s]{10,15}$/;


Now it's still not very useful because you allow an arbitrary number of punctuation characters too. Really, validating a phone number like this — especially if you want it to really work for all possible international phone numbers — is probably a hopeless task. I suggest you go with what @BalusC suggests.


[#95017] Monday, November 8, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
valentinam

Total Points: 166
Total Questions: 117
Total Answers: 81

Location: Puerto Rico
Member since Sun, Jun 27, 2021
3 Years ago
;