Solved

Phone Number Validation VB.Net

Posted on 2008-10-28
2
1,745 Views
Last Modified: 2012-05-05
I already have a code snipet that validates the phone number is in the correct string format. I was wondering if anyone knew of a way to try and make sure the phone number is as valid as possible. ie the user did not enter all 111-111-1111 or 123-456-7890 and so on

Any thoughts ?
0
Comment
Question by:jimseiwert
2 Comments
 
LVL 16

Accepted Solution

by:
HooKooDooKu earned 500 total points
ID: 22824850
The proplem is that you are talking about a moving target.  A phone number (U.S.) consists of an Area code and what is known as an NXX and 4 more digits.  There is a limited set of valid Area Codes and NXX values.  But new area codes keep getting added all the time, and new NXX codes are getting added to each area code.

So to obtain what you are looking for, you would have to have some sort of service that updates what constitutes a valid value on a regular basis. (Such products do exist... as an example of what I could find with a quick search is www.area-codes.com).

On the other hand, you could right a simplistic subroutine to do a sanity check against current basic rules for phone nubers.  For example, the area code can't be any of the special numbers like 555, #11 (like 911 and 411) & 999, and no area codes start with 1.  Do some Googling on Area code lists or NXX lists and you'll find additional information.
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 22824867
You can use a maskedtextbox for that. It will make the validation for you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 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

20 Experts available now in Live!

Get 1:1 Help Now