Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RequiredFieldValidator Help

Status
Not open for further replies.

fmrock

Programmer
Sep 5, 2006
510
US
I am trying to fix the color of the RequiredFieldValidator on a form that was created for my company.

Here is the code for the validator.
Code:
<asp:TextBox ID="Name" runat="server" TabIndex="3"></asp:TextBox>
                              <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                  ControlToValidate="Name" CssClass="validation-advice" 
                                  ErrorMessage="<br /> is required" SetFocusOnError="True" Display="Dynamic"></asp:RequiredFieldValidator>

Here is the CSS Class

Code:
.validation-advice {
  /*color: #990000;*/
  color: #B31212;
  font-size: smaller;
}
[/]

However, changing the color in the sytle sheet does not change when this is run.

When I view the source of the page I see that the color is set inside of a style property.

[code]
<span id="RequiredFieldValidator1" class="validation-advice" style="color:Red;display:none;"><br /> is required</span>

Any ideas on where i should look to see what is seting this style?

style="color:Red;display:none;"
 
I found if you use ForeColor=" " then it will use my CSS
 
This is all to do with the specificity of how css is applied within a browser. I suspect that changing your stylesheet to:
Code:
.validation-advice {
  color: #B31212 [!]!important[/!];
  font-size: smaller;
}
should do the trick though.


Mark,

Darlington Web Design[tab]|[tab]Experts, Information, Ideas & Knowledge[tab]|[tab]ASP.NET Tips & Tricks
 
Thanks, I saw that trick also when doing a google search, but someone said it didnt work in all browsers.

Thanks for your ressponse.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top