stretch73
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
TIA,
N
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@fanopoe:
\d{13} will take "0000000000000", or "0100000000000", etc, as valid numbers,
\d{13} will take "0000000000000", or "0100000000000", etc, as valid numbers,
ASKER
This did not work:
<asp:RegularExpressionVali dator ID="rfvBillingAccountNumbe r"
ControlToValidate="txtBill ingAccount Number"
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"/>
<asp:RegularExpressionVali
ControlToValidate="txtBill
ValidationExpression="^[1-
ErrorMessage="A billing account number must be 13 digits, numeric, and is required to add a customer."
Display="dynamic"
runat="server"/>
ASKER
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.
^[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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks PD and fanopoe, exactly what I needed.
N
N
^[1-9]\d{12}$