473,545 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parsing phone numbers

I'm curious if there are others who have a better method of
accepting/parsing phone numbers. I've used a couple of different techniques
that are functional but I can't really say that I'm totally happy with
either.

1. My first technique was to restrict the users to entries that could only
be 3 character, 3 characters, 4 character (area code, prefix, suffix,
respectively). I would null out any inputs that were non-numeric (except the
backspace). This worked reasonably well, except it was somewhat ugly to look
at.

2. My second technique was to give the user a single text entry box and
auto-format the string with hyphens as they entered the phone number. I then
parse the phone number, knowing exactly where the hypens are located.

What I'm looking for is some better ideas. Anyone?
Nov 22 '05 #1
4 5246
> What I'm looking for is some better ideas. Anyone?
Yes. Trust the user and accept more.
Why:
- numbers having extensions
- numbers with letters: 1-800-COLLECT
- numbers outside U.S.

I always get annoyed when I can't imput my data on some web sites
and quite a few of them lost me as a buyer.
Same with registration forms.

--
Mihai
-------------------------
Replace _year_ with _ to get the real email
Nov 22 '05 #2
On Sun, 23 May 2004 01:56:52 -0500, "Earl" <brikshoe<at>co mcast<.>net>
wrote:
I'm curious if there are others who have a better method of
accepting/parsing phone numbers. I've used a couple of different techniques
that are functional but I can't really say that I'm totally happy with
either.

1. My first technique was to restrict the users to entries that could only
be 3 character, 3 characters, 4 character (area code, prefix, suffix,
respectively ). I would null out any inputs that were non-numeric (except the
backspace). This worked reasonably well, except it was somewhat ugly to look
at.

2. My second technique was to give the user a single text entry box and
auto-format the string with hyphens as they entered the phone number. I then
parse the phone number, knowing exactly where the hypens are located.


My personal preference is to let the user type what they want. Give
them a free entry text box. Then, in validation code (client or server
depending on your whims) you parse out what I typed and deal with it.
If I want to use dashes, thats up to me. If I want to use spaces,
thats my choice too. Now, if you want to reformat what I typed with
nice parentheses and dashes, thats your choice too - as long as what
you reformat it to is correct based on what I typed :)

Bottom line, the WORK should be on the programmers side - not the
users side.
Nov 22 '05 #3
I'm with Dan on this one. I'd include that the if your scheme does impose
some restriction, make sure that you have a clear example next to the text
box in a label or something that makes the requirements clear as day.
However, there are times that even with the documentation or examples, the
restrictions are ridiculous and still annoying. Having three or four
textboxes is another approach that's easier, so that the delimmiter doesn't
matter. Just make sure that the field auto tabs to the next one so that the
user doesn't have to hit tab if you use this method b/c it's really annoying
to have to tab twice or three times just to type in a number.

HTH,

Bill

--
W.G. Ryan MVP Windows - Embedded

www.devbuzz.com
www.knowdotnet.com
http://www.msmvps.com/williamryan/
"Earl comcast net>" <brikshoe<at. > wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I'm curious if there are others who have a better method of
accepting/parsing phone numbers. I've used a couple of different techniques that are functional but I can't really say that I'm totally happy with
either.

1. My first technique was to restrict the users to entries that could only
be 3 character, 3 characters, 4 character (area code, prefix, suffix,
respectively). I would null out any inputs that were non-numeric (except the backspace). This worked reasonably well, except it was somewhat ugly to look at.

2. My second technique was to give the user a single text entry box and
auto-format the string with hyphens as they entered the phone number. I then parse the phone number, knowing exactly where the hypens are located.

What I'm looking for is some better ideas. Anyone?

Nov 22 '05 #4
Interesting ideas.

In some earlier apps, I have already implemented the multiple text box
scheme (with auto-focus). I've rejected that approach for this one.

International codes are irrelevant to this particular app since the
customer's phone number must, by definition, be a U.S. resident. However I
did allow for this in the database design, as well as extensions, which
might be more relevant and more problematic.

I'm not terribly inclined to allow "numbers" such as 1-800-COLLECT for the
simple reason these are advertiser conversions that are transparent and
would have to be re-parsed even though the user should already know the
number (without another parsing, searching on an exchange would create other
difficulties). This is certainly do-able but I would expect business users
to be bright enough to figure out what the real number was. It is food for
thought though, and I will put that one in my notes for a later date.

It would be great to implement Dan's idea about allowing ANYTHING to be
entered. But I'm not convinced we can make structure out of non-structure.
It seems to me that there has to be some bare-bones structure to what a user
can enter.

Otherwise, do we not hit a point of diminishing returns by anticipating and
parsing every potential scenario? Or do we end up with a Telemagic database,
where users have failed to do some semblance of formatting and the system
just blindly accepts whatever was entered? Ditto for the Act! method of
dealing with phone numbers, which once again allows the user to enter
"free-form", but indeed does not deal with every concatentation and parsing
potential and thus ends up with some pretty screwball phone numbers. In
fact, I have yet to see one commercial product that has successfully dealt
with this issue to the point where a user can enter anything they would like
and have the system turn it into a viable phone number.

While these have been great ideas to get me to thinking, I think for now I'm
going to continue to use my latest method, where I allow the user to enter
whatever they want -- in a single text box -- but null out everything but
numerals. I auto-format a dash as the number goes in, then move them out of
the entry box when they hit 12 characters. Extensions are going to have to
be dealt with separately.

Thanks all for sharing your thoughts.

"William Ryan eMVP" <do********@com cast.nospam.net > wrote in message
news:ug******** ******@TK2MSFTN GP11.phx.gbl...
I'm with Dan on this one. I'd include that the if your scheme does impose
some restriction, make sure that you have a clear example next to the text
box in a label or something that makes the requirements clear as day.
However, there are times that even with the documentation or examples, the
restrictions are ridiculous and still annoying. Having three or four
textboxes is another approach that's easier, so that the delimmiter doesn't matter. Just make sure that the field auto tabs to the next one so that the user doesn't have to hit tab if you use this method b/c it's really annoying to have to tab twice or three times just to type in a number.

HTH,

Bill

--
W.G. Ryan MVP Windows - Embedded

www.devbuzz.com
www.knowdotnet.com
http://www.msmvps.com/williamryan/
"Earl comcast net>" <brikshoe<at. > wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I'm curious if there are others who have a better method of
accepting/parsing phone numbers. I've used a couple of different

techniques
that are functional but I can't really say that I'm totally happy with
either.

1. My first technique was to restrict the users to entries that could only be 3 character, 3 characters, 4 character (area code, prefix, suffix,
respectively). I would null out any inputs that were non-numeric (except

the
backspace). This worked reasonably well, except it was somewhat ugly to

look
at.

2. My second technique was to give the user a single text entry box and
auto-format the string with hyphens as they entered the phone number. I

then
parse the phone number, knowing exactly where the hypens are located.

What I'm looking for is some better ideas. Anyone?


Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
420
by: Earl | last post by:
I'm curious if there are others who have a better method of accepting/parsing phone numbers. I've used a couple of different techniques that are functional but I can't really say that I'm totally happy with either. 1. My first technique was to restrict the users to entries that could only be 3 character, 3 characters, 4 character (area...
10
14285
by: JackM | last post by:
I'm still working on validating the phone numbers that are entered on a form but have come across a problem I don't understand how to fix. I can handle most instances when it's in regular US formats (555-555-5555 or (555) 555-5555 or 555 555 5555) but I'm having trouble when the entry is ten consecutive numbers with nothing else (5555555555)....
3
6752
by: venu | last post by:
Hi, I have a different requirement and it is : I need to validate a phone number field. It may or may not be a US phone number. The constraints are : *********************** # It should accept any number of numbers
5
1862
by: gvidak | last post by:
Hello Guys, Yes, another beginner in C++ and I have a homework assignment that is giving me a headache. Can someone help me with the following problem? I have a text file with names, phone numbers and addresses. I have to ask the user to input first name, last name then with a function call I have to find this name in my text file. The trick...
7
4638
by: laredotornado | last post by:
Hi, Using php 4.4.4, I am looking to parse a US phone number string into 3 smaller strings -- area code, the first part of the phone number (3 digits) and the last part of the phone number (4 digits). The only given is that there will be 10 digits in the string, but people may include spaces, parens, or other characters. These are all...
4
3131
by: lilOlMe | last post by:
I'd love to be able to validate phone numbers in my software but my product is being used world wide. Not everyone's phone number is formatted like USA/Canada formats theirs. I've found a few sites that told me how international phone numbers are formatted and can figure out how to validate them quite easily from that... But it doesn't...
5
3283
by: lim4801 | last post by:
I am currently in doing a program which is given by my tutor: Contemplate that you are working for the phone company and want to sell "special" phone numbers to companies. These phone numbers are "special" because they are easily translated into words. You've been asked to create a list of phone numbers that are directly mappable to words by...
4
2508
by: Blue Streak | last post by:
Hello, Folks! Does anyone know of a website that lists the local phone number formats for each country? TIA...
7
3858
by: Propoflady | last post by:
My contacts can have as many as five or six phone numbers - is it possible to make a query that puts the name, and each phone number after it on the same line - for this reason I have two tables - client and phone linked by client id right now I get contact a - phone number 1 contact a - phone number 2 I would like
0
7468
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7808
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7757
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
704
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.