0

I'm doing this to set a border around input fields:

input[type=text], input[type=password], textarea { border: 1px solid #9BAF31;}

I have client-side validation that adds this class when errors occur:

.input-validation-error {
    border: 1px solid #ff0000;
    background-color: #ffeeee;
}

But only the background is set. The border is still the original color. How can i set it with the validation color?

2
  • your first declaration probably overrides your second. how about border: 1px solid #ff0000 !important ? it would also be better if you provided a sample in jsfiddle to better diagnose this Commented Mar 7, 2011 at 10:16
  • !important is a one shot sledgehammer, it is best avoided as it often leads to "I wish there was a double !important method" situations. Get the specificity right instead. Commented Mar 7, 2011 at 10:18

3 Answers 3

1

Have you tried

input[type=text].input-validation-error ,input[type=password].input-validation-error, textarea.input-validation-error
{
    border: 1px solid #ff0000;
    background-color: #ffeeee;
}
Sign up to request clarification or add additional context in comments.

Comments

1

You need to make the rule you want to apply at least as specific as the existing rules.

2 Comments

in this case how do i make it at least as specific?
Follow the link to see the rules for specificity.
0

You could try to add the .input-validation-error above the "input[type=text],input[type=password], textarea". Also, what does FireBug says when you inspect the element?

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.