473,503 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regular Expression for Phone Number

I have a textbox (txtPhoneNumber) that either has to contain 10 numbers (no
other characters) and cannot start with a 1. However... either this textbox
must contain a valid numbr (10 digits and cant start with 1) or it can be
totally blank. What is the best reg expression to use? How is it built?
Are there good utils out there to define expressions?
Thanks a lot.
Jan 15 '07 #1
2 17331
See
http://www.regexlib.com
Hope that helps
Patrick

"Jake K" <msnews.microsoft.comwrote in message
news:uN*************@TK2MSFTNGP03.phx.gbl...
>I have a textbox (txtPhoneNumber) that either has to contain 10 numbers (no
other characters) and cannot start with a 1. However... either this
textbox must contain a valid numbr (10 digits and cant start with 1) or it
can be totally blank. What is the best reg expression to use? How is it
built? Are there good utils out there to define expressions?
Thanks a lot.


Jan 15 '07 #2
On Sun, 14 Jan 2007 22:50:44 -0500, Jake K wrote:
I have a textbox (txtPhoneNumber) that either has to contain 10 numbers (no
other characters) and cannot start with a 1. However... either this textbox
must contain a valid numbr (10 digits and cant start with 1) or it can be
totally blank. What is the best reg expression to use? How is it built?
Are there good utils out there to define expressions?
Thanks a lot.
ASP.NET regex validators seem to let through controls with no text so
blanks won't be a problem. As for the digits try this regex:

^[0,2-9]\d{9}$
--
Bits.Bytes
http://bytes.thinkersroom.com
Jan 15 '07 #3

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

Similar topics

8
6968
by: Eric Linders | last post by:
Hi, I'm trying to figure out the most efficient method for taking the first character in a string (which will be a number), and use it as a variable to check to see if the other numbers in the...
5
19203
by: joemono | last post by:
Hello everyone! First, I appologize if this posting isn't proper "netiquette" for this group. I've been working with perl for almost 2 years now. However, my regular expression knowledge is...
1
1493
by: Al Jones | last post by:
This was originally posted in the VBScript forum, several of my other questions have been vbscript related, one of the fine fellows there suggest I might want to post it as well in the jscript...
0
5669
by: Brian Davis | last post by:
The problem is in the word boundary \b. A leading "(" will match as a word boundary before it gets to the test for a "(". Changing the expression to: (?n)(\b|\()1??\(?(?<areaCode>\d\d)?\)??(?...
4
1744
by: Arne | last post by:
Hi, I'm trying to recognise phone numbers on the following format using regular expressions: +47 123 45 678 This should be recognised by the following regular expression: +47 \d{3} \d{2}...
2
3994
by: Ori | last post by:
Hi, I'm looking for a good way to validate a US phone number and i though using regular expression for this. I want to support 3 different ways to enter a phone number: 1.Local Phone : 888-8899...
5
1765
by: mac.speed | last post by:
Hi! i have set of over 100+ regular expressions, instead of checking user input against these regex i want to store all possible matches in a database and search against them. like if a regex...
2
1387
by: kieran | last post by:
Hi, I am using Visual Studio 2005 and am trying to use a Regular Expression Validator control. I have a drop down list which contains various names, the first one is "Please Select". I want...
1
2117
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...
3
6748
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...
0
7202
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,...
0
7086
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...
0
7330
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...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
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...
1
5014
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...
0
4672
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...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.