Solved

RegularExpressionValidator - Numeric 13 characters

Posted on 2008-10-09
10
645 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
Independent Software Vendors: 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

740 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