Example of a regular expression for phone numbers

Viewed 89216

I'm very new to javascript, I just want a reqular expression for validating phone numbers for one of my text field.

I can accept -+ () 0-9 from users, do you have regex for this one or a regex for phone numbers better then the one i need?

Thanks in advance.

6 Answers

For global users have a look into this library libphonenumber-js.

this will let you validate global mobile numbers.

This regex works pretty widely for phone numbers:

^(\+)?(\d{1,2})?[( .-]*(\d{3})[) .-]*(\d{3,4})[ .-]?(\d{4})$
Related