Validating phone numbers in
In forms when asking for phone numbers fields it is a good idea to use client side validation along with your programming language validation.
Almost every editor on every computer system can do this.
Regular expressions are more powerful and flexible. You can search Numbers, punctuation characters, patterns and so on.
Click here for NANP phone number validation and US only phone number validation.
A couple of days ago, I revisited that post and realized how inefficient my function actually was.The general standard is 00 and this has been implemented by a large number of countries.For North American Numbering Plan (NANP) countries (including the United States and Canada) the call prefix is "011" for other countries and "1" for countries inside the NANP.Similarly if we want to validate phone number like xxx-xxx-xxxx format then you can use “\d-\d-\d”.If you want to use regular expression for validating phone or mobile numbers followed by country code.