Solved

Phone Number Validation VB.Net

Posted on 2008-10-28
2
1,752 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Call windows 10 virtual keyboard from windows forms app 2 52
How to limit User Input 2 27
Code enhancement 4 22
vb.net convert long time to mm:ss 23 13
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
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…

830 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