?
Solved

RegularExpressionValidator - Numeric 13 characters

Posted on 2008-10-09
10
Medium Priority
?
648 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 400 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
A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

 
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 1600 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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 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