Solved

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

Posted on 2014-12-15
9
149 Views
Last Modified: 2014-12-16
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?
0
Comment
Question by:grovenetsupport
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 33

Expert Comment

by:paulmacd
Comment Utility
Using some sort of RegEx would be the right way to go.  How you implement it depends on the technology you're using.
0
 
LVL 25

Expert Comment

by:Ron M
Comment Utility
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
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
Are you asking to verify the format of the phone number or if the phone number itself is real and valid?
0
 

Author Comment

by:grovenetsupport
Comment Utility
Both as we receive leads via a web form from joe public and they are forever putting wrong phone numbers in?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:grovenetsupport
Comment Utility
PS needs to be UK version
0
 
LVL 33

Accepted Solution

by:
paulmacd earned 500 total points
Comment Utility
Again, without knowing any of the technology you're using, this should get you started.
0
 

Author Comment

by:grovenetsupport
Comment Utility
Cms is umbraco if that helps?
0
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
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
 
LVL 33

Expert Comment

by:paulmacd
Comment Utility
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now