views:

16

answers:

1

I'm using ASP.NET WebForms and using some validation like the following:

<asp:TextBox  runat="server" ID="txtUserName" CssClass="Email" /><br />
<asp:RequiredFieldValidator runat="server" ID="rfvUserName" Display="Dynamic" ControlToValidate="txtUserName" ErrorMessage="Please enter your email address" CssClass="Error" />
<asp:RegularExpressionValidator Enabled="false" runat="server" ID="revUserName" Display="Dynamic" ControlToValidate="txtUserName" ErrorMessage="Please enter a valid email address" ValidationExpression="<%$ Resources:Global, RegExEmail %>" />

What I want to do is instead of just showing a message below in the form of a span I would like to alter the textbox itself, such as add a red border around it and change its background to have an error icon. How do I do this? Thanks.

+1  A: 

Hello, what about ValidatorCallout?

It looks nice and let you add custom CSS class to validated field when it's content is invalid.
Also it's a part of popular Ajax Toolkit by Microsoft.

ŁukaszW.pl