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.
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.