My current form contains around 10 controls, similar to the one below:
<asp:TextBox ID="fullname" Width="200" MaxLength="50" runat="server"/>
<asp:RequiredFieldValidator Display="Dynamic" ValidationGroup="contact" ControlToValidate="fullname" ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"/>
I appreciate how ASP.NET fieldvalidators function, but I would like to customize the way validation errors are displayed. Instead of showing an asterisk when validation fails, I want to highlight the input field in red.
To achieve this, I intend to use jQuery for more control over CSS and animations. I prefer this method over ASP.NET animations, which I find overly complex.
I came across a post on Stack Overflow that discussed a similar issue (Change Text Box Color using Required Field Validator. No Extender Controls Please), but it did not provide a clear solution.
So, my question is: Is there a way to retain my ASP.NET validator controls while changing the way error messages are displayed? Can I use jQuery to add or remove animations and CSS classes to the validated input fields instead?
Requirements:
- The code should work for requiredfieldvalidator and regularexpressionvalidator, among others.
- It should capture the enter key press event.
- Error CSS should be removed when the user corrects the input field and validation succeeds.
Thank you!