Reputation: 11
<input id="x_card_num" name="x_card_num" type="text" value="<%: CreditCardNumber %>"required="required" maxlength="16" />
<asp:RegularExpressionValidator runat="server" ControlToValidate="x_card_num" ValidationExpression="/^[0-9]{16}/" ErrorMessage="invalid Card Number" ID="RegExCardnumber">
</asp:RegularExpressionValidator>
When I use this regular expression, I am getting the error:
controltoValidate id not found.
Upvotes: 1
Views: 120
Reputation: 62290
Error message said it all. You need to assign ControlToValidate like this -
<asp:TextBox ID="EmailTextBox" runat="server" ... />
<asp:RegularExpressionValidator ControlToValidate="EmailTextBox" ... />
If you want to validate regular HTML control, you need runat="server"
.
<input ... runat="server" />
Upvotes: 1