Solved

RegularExpressionValidator - Numeric 13 characters

Posted on 2008-10-09
10
635 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
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
 
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A short film showing how OnPage and Connectwise integration works.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

919 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now