1

We are developing an eCommerce platform and would require a valid phone number. Now dealing with UK, USA and other international countries.

what we are finding difficult is allowing the UK variants along with the USA variants. We have found many expressions for USA format but these dont work with the format.

We need to allow both internal UK aswell as the eternal +44 prefix along with the USA formats and any other international (mainly europe) formats.

We are considering just removing any ()+- characters and validating the rest to be numeric between 7 and 15, unless there is an all encompassing regular expression

Kara
  • 6,115
  • 16
  • 50
  • 57
Wardy277
  • 33
  • 6
  • 1
    Domain registration systems "solve" this problem by enforcing a standard format: `+1.234567890` - that is, `+`, country code, `.`, rest of numbers. If you don't give it that format, no domain registration for you. It can be a hassle, but it's a pretty sure-fire way to ensure you get a phone number that at least looks valid. That said, you're really only interested in the digits so consider just stripping everything else and see what you have left. – Niet the Dark Absol Jul 09 '14 at 16:28
  • Might help: https://code.google.com/p/libphonenumber – oliakaoil Jul 09 '14 at 16:32
  • Also take a look here: http://stackoverflow.com/questions/123559/a-comprehensive-regex-for-phone-number-validation – ex3v Jul 09 '14 at 16:41
  • I'd maybe give this input mask plugin a try. The example under multi masks uses phone numbers as an example. https://github.com/RobinHerbots/jquery.inputmask#multi-masks – Overachiever Jul 09 '14 at 16:52

0 Answers0