Regular expression for validating phone number in javascript stephane lambiel johnny weir dating

Posted by / 24-Jul-2017 10:18

Regular expression for validating phone number in javascript

We will use the intl-tel-input plugin for that purpose.

The first function tests for exactly 10 nonspace characters with \S.

A few searches later and I was amazed at how complex the expressions needed to be, in order to account for any possible format that a user may enter data.

For example, our phone number could be entered as any of the following: 089733319408 9733 3194(08) 9733 3194 And there are probably a lot more combinations.

If that wasn't the cause of failure, the string is tested for too many characters—11 or more with . In the second pattern we are looking for a valid Java Script variable name of ten characters.

Java Script restricts the first character to letters, $, or an underscore.

regular expression for validating phone number in javascript-25regular expression for validating phone number in javascript-74regular expression for validating phone number in javascript-80

Therefore, despite the fact that it doesn't cover all possible formats of phone number in the world, you can use the regexp validator to test a phone number in your country.