Hi. I am trying to validate a MaskedTextBox in Asp.net using a RegularExpressionValidator control. The validation works on a normal textbox, but I can't get it to work on the MaskedTextBox. I'm getting the error message Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Here is my code:
<
telerik:RadMaskedTextBox
ID
=
"txtFederalTaxID"
runat
=
"server"
Mask
=
"##-#######"
CssClass
=
"field"
SelectionOnFocus
=
"SelectAll"
>
</
telerik:RadMaskedTextBox
>
<
asp:RequiredFieldValidator
ID
=
"RequiredFieldValidator28"
runat
=
"server"
ErrorMessage
=
"*"
ControlToValidate
=
"txtFederalTaxID"
InitialValue
=
""
ValidationGroup
=
"Terms"
></
asp:RequiredFieldValidator
>
<
asp:RegularExpressionValidator
ID
=
"RegularExpressionValidator1"
ControlToValidate
=
"txtFederalTaxID"
runat
=
"server"
ValidationExpression
=
"^(?!(\d)\1+$|(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)|9(?=0)){5}\d$|(?:0(?=9)|1(?=0)|2(?=1)|3(?=2)|4(?=3)|5(?=4)|6(?=5)|7(?=6)|8(?=7)|9(?=8)){5}\d$)\d{9}$"
ErrorMessage
=
"Invalid!"
Width
=
"20px"
></
asp:RegularExpressionValidator
>