Solved

RegularExpressionValidator - Numeric 13 characters

Posted on 2008-10-09
10
647 Views
Last Modified: 2013-12-17
New-ish to regular expressions and this is driving me nuts.  I've got a RegularExpressionValidator and I need the input to be a number at least 13 characters long.  I'm sure this is a snap but I cannot get it right.

TIA,

N
0
Comment
Question by:stretch73
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 11

Assisted Solution

by:fanopoe
fanopoe earned 100 total points
ID: 22680485
this should get you started:

"\d{13}"

see below usage


hth
<asp:TextBox ID="txtTest" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="rev01" runat="server" ControlToValidate="txtTest" Text="Error" ValidationExpression="\d{13}">

Open in new window

0
 
LVL 22

Expert Comment

by:prairiedog
ID: 22680493
Will this do?
^[1-9]\d{12}$
0
 
LVL 32

Expert Comment

by:Daniel Wilson
ID: 22680494
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:prairiedog
ID: 22680511
@fanopoe:
\d{13} will take "0000000000000", or "0100000000000", etc,  as valid numbers,
0
 

Author Comment

by:stretch73
ID: 22680539
This did not work:

<asp:RegularExpressionValidator ID="rfvBillingAccountNumber"
                                    ControlToValidate="txtBillingAccountNumber"
                                    ValidationExpression="^[1-9]\d{12}$"
                                    ErrorMessage="A billing account number must be 13 digits, numeric, and is required to add a customer."
                                    Display="dynamic"
                                    runat="server"/>
0
 

Author Comment

by:stretch73
ID: 22680549
Thank you for the suggestions, but will these also validate against no input either?
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 22680552
After reviewed the original question, I changed my expression to this:
^[1-9]\d{12,}$  ''<== Added a comma to meet the requirement: at least 13 characters long
Note: [1-9] will ensure that numbers with leading 0 are not allowed.
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 22680566
You will need a RequiredFieldValidator again no input value.
0
 
LVL 22

Accepted Solution

by:
prairiedog earned 400 total points
ID: 22680586
Your error message says "A billing account number must be 13 digits, numeric, and is required to add a customer.". It does not match your original requirements: at least 13...
My first solution matches numbers with exactly 13 digits, and the modified solution matches numbers with at least 13 digits.
0
 

Author Closing Comment

by:stretch73
ID: 31504736
Thanks PD and fanopoe, exactly what I needed.

N
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

695 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