Link to home
Start Free TrialLog in
Avatar of stretch73
stretch73Flag for United States of America

asked on

RegularExpressionValidator - Numeric 13 characters

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
SOLUTION
Avatar of fanopoe
fanopoe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Will this do?
^[1-9]\d{12}$
@fanopoe:
\d{13} will take "0000000000000", or "0100000000000", etc,  as valid numbers,
Avatar of stretch73

ASKER

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"/>
Thank you for the suggestions, but will these also validate against no input either?
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.
You will need a RequiredFieldValidator again no input value.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks PD and fanopoe, exactly what I needed.

N