Im having issues with the RegularExpressionValidator in my code!
I have 2 text boxes in my html page and in the code i have the sql command that inserts the parameters to the DB, the issue is that if i put a special character to the text box the sql stops because i need the validators, so i tried validating like this.
Insert the files number.
<asp:TextBox ID="TextBox1" runat="server" MaxLength="10" ></asp:TextBox>
Whats the users Name <br />
<asp:TextBox ID="TextBox2" runat="server" MaxLength="10"></asp:TextBox>
The validator is defined as:
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ErrorMessage="RegularExpressionValidator" ValidationExpression="^\d+$"
ControlToValidate="TextBox1"></asp:RegularExpressionValidator>
But when loading it ignores my validation expresion.
Please what is missing.
Thanks
If you want to see a mark next to the field when validation fails, you should set the
Text
property of the validator:Also, if you want to see the error message, you must have a
ValidationSummary
in your form.I checked everything and finally got it,
I had to add to my
web.config
the following:And that solved my issues