Phone validation regex

Nir picture Nir · Dec 26, 2011 · Viewed 253.9k times · Source

I'm using this pattern to check the validation of a phone number

^[0-9\-\+]{9,15}$

It's works for 0771234567 and +0771234567, but I want it to works for 077-1234567 and +077-1234567 and +077-1-23-45-67 and +077-123-45-6-7

What should I change in the pattern?

Answer

Gent picture Gent · Dec 26, 2011

Please refer to this SO Post

example of a regular expression in jquery for phone numbers

/\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/
  • (123) 456 7899
  • (123).456.7899
  • (123)-456-7899
  • 123-456-7899
  • 123 456 7899
  • 1234567899

are supported