Whats the best way to validate a phone number is correct on a web form

Is there a good way to check a phone number is correct on a web form like a postcode lookup to find the address. We already check the digits but is there a better way?
grovenetsupportAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Paul MacDonaldConnect With a Mentor Director, Information SystemsCommented:
Again, without knowing any of the technology you're using, this should get you started.
0
 
Paul MacDonaldDirector, Information SystemsCommented:
Using some sort of RegEx would be the right way to go.  How you implement it depends on the technology you're using.
0
 
Ron MalmsteadInformation Services ManagerCommented:
There are caveats to this..
You can check if a phone number has a valid area code and prefix.. but you can't be sure that it is a working number, or that the number hasn't been "ported" to a cellphone.  To do this you would need a database through NANPA.com

If you just want to check the area code.. you can get the list here nanpa
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Jason C. LevineNo oneCommented:
Are you asking to verify the format of the phone number or if the phone number itself is real and valid?
0
 
grovenetsupportAuthor Commented:
Both as we receive leads via a web form from joe public and they are forever putting wrong phone numbers in?
0
 
grovenetsupportAuthor Commented:
PS needs to be UK version
0
 
grovenetsupportAuthor Commented:
Cms is umbraco if that helps?
0
 
Jason C. LevineNo oneCommented:
Verifying the format of a phone number is pretty simple.  I'm sure Umbraco has a form handler that can validate different types of inputs and you can work with it from there.  To properly validate a phone number, you do need to use both client and server-side validations and regular expressions, so follow on with paulmacd's suggestions to get started.

Validating to see if the phone number is actually correct and rings an actual phone is a completely different animal.  Broadly speaking, there are two ways to go about it:

1) Use a database/API such as http://www.phone-validator.net/ and check the submitted number that way.  I have some doubts as to the accuracy of databases and APIs

2) Instead of checking the number, actually call the phone number entered by the user and have them enter a code that is read to them by a computer-generated voice.  This is broadly similar to two-factor authentication used to secure logins.  If you can get away with only demanding a mobile number, you can make this a lot easier by texting the code to the user instead of doing the audio call.
0
All Courses

From novice to tech pro — start learning today.