473,883 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

US phone number validation

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). Not only does it
not validate, but it shows as 2147483647 when I call the variable to
check to see how it is set. I know I could break the form up into three
values as in <input name="phone[area]"> <input name="phone[code]"> and
<input name="phone[num]"> to eliminate that happening but I don't like
the look of that and I know there's a better way that I haven't found.

I tried googling for information on a preg_replace statement that could
do what I need (check the phone number and add a space between the 3rd
and 4th and the 6th and 7th digits if there isn't one there already) but
I haven't been successful.

What do I need to do to handle this?
Apr 8 '06
10 14319
NC wrote On 04/13/2006 12:02 PM:
Richard Levasseur wrote:
Are you sure about that? Is 1 not the US/CA country code?


Not exactly. When you call from outside North America, 1 is indeed the
U.S. country code. When you call from the U.S. and the first number
you dial is 1, it's a signal for the telephone exchange to switch from
local to long-distance dialing. The exchange assumes that the 10
digits after the 1 are a three-digit area code followed by a
seven-digit phone number.


Almost, but it is a bit more complex then that. If you start your
number with '10', the next three digits are then assumed to be the
actual long distance carrier that you wish to use for placing a long
distance call. So the number string becomes 15 digits. Also, this only
works from a POTS landline. It could be used in a database to indicate
that it's cheaper to use AT&T, say, in one particular special example,
though it probably wouldn't be useful enough to figure in. Nonetheless,
I have had people that have fed me phone numbers in that crazy format
before and it was confusing. (Strange people.)

- Mike
Apr 15 '06 #11

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

Similar topics

21
6271
by: AnnMarie | last post by:
<script language="JavaScript" type="text/javascript"> <!-- function validate(theForm) { var validity = true; // assume valid if(frmComments.name.value=='' && validity == true) { alert('Your full name is required. Please enter your full name!'); validity = false; frmComments.name.focus();
5
3532
by: Kamaluokeakua | last post by:
I have to write an application that deals with clients in multiple countries. The addresses, phone numbers, country id and currency information has to be stored into a database that allows for the format of any country. I would like to be able to automatically display the information in the format of their country based on the information gathered from the Country field in the database. Is there any white paper, or book or site that has...
4
11743
by: Srinivas Kollipara | last post by:
Hey guys, i have a small question in C#. I have a windows form which has Address fields, zip code and phone number fields. it is working fine with U.S. but i need to modify that for all the other countries. is there any way i can validate zipcode and phone numbers.... Thanks in advance. bye Srinivas
2
3280
by: Jeff Kiesel | last post by:
Has anyone used three textboxes for phone number input and successfully validated it? One textbox for area code, one for exchange, one for number. (yes, we're only doing US numbers) :o)
2
2249
by: Sharon Traineanu via .NET 247 | last post by:
I'm using C#.net. I have a phone number in three asp textboxes. I'd like to make the phone number required, and validate to make sure only numbers have been entered. My main problem is I can't find a way to have all three textboxes use the same validator and not display 3 error messages. -------------------------------- From: Sharon Traineanu -----------------------
6
27714
by: Michael R | last post by:
I haven't found anything that would help me to understand the correct syntax for having a certain number of digits phone number validation rule. My input mask for this field is: \000\-0000000;; When I set the following validation rule: 9999999999 or =9999999999 it doesn't work correctly and it allows short numbers. How should I compose it correctly. Thanks, Michael.
3
2254
by: ryushinyama | last post by:
I am wanting to remove 1's that Canadian customers put in front of their numbers because when FedEx imports them for shipping they leave the 1 and cut off the last number. Other countries numbers don't get formatted the same so they are not an issue. The code below was an attempt to remove a one at the beginning if present at all. Which should get the job done but I don't know if there are countries out there that need to start in the...
2
3094
by: ajaymohank | last post by:
Hello friends............ i am trying to get a validation for email and phone number. in my php project i am doing the validation using java script. but i am not getting validations for email and phone number correctly... please give a solution for this..
1
2107
by: thulaseeram | last post by:
Hi to All, I am using general javascript function isNAN to validate whether entered input is number or not it is doing ok. But it should take space in between code number and phone number. for Example: now it it is taking 078245378 (not allowing spaces, This is existing validation) but it should allow space like 078 245378. Please can any one help me how to validate this(i mean how to...
0
9945
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11157
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10763
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10422
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9586
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7978
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7136
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4622
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3241
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.