2

I'm using jQuery validate on a form I am building and it is working great. What I want to do is when something is invalid to have the text field change colors and the error message to be white. I figured the following CSS would work:

label .error {color: white; font-weight: bold;}
input .error {background-color: pink; border: 1px dashed red; color: white}

When I test the validation the above CSS doesn't seem to apply. I checked using Firebug and the label and input area have the 'error' class applied.

The CSS seems valid as when I leave off the .error clause everything looks like I want it too. What am I doing wrong?

2 Answers 2

13

One space can be one too much. Try:

label.error {color: white; font-weight: bold;}
input.error {background-color: pink; border: 1px dashed red; color: white}

Background info:

label .error  /* selects all elements of class "error" *within* any label */
label.error   /* selects labels of class "error"                          */
Sign up to request clarification or add additional context in comments.

1 Comment

Bang. Nailed it. Nice catch, Tomalak!
3

Try label.error and input.error without spaces.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.