1

I have this in my CSS file that styles input fields in a form:

input,textarea,input,select,input,checkbox {
    font-size:12px;
    font-family:Verdana,Arial,Helvetica,sans-serif;
    color:#98925C;
    background-color:#000;
    border:1px solid #413E22;
}

When I use a disabled on the form though (eg the submit button when pressed), it doesn't grey out like it should.

I have this in the submit button HTML

onclick="this.disabled=true;this.value=' done ';this.form.submit();"

How can i make it so the button greys out once clicked?

4 Answers 4

3

It does gray out in IE. For other browsers, though, you need to specifically define your "disabled element" styles with:

:disabled {
    color: #6b849a;
    text-shadow: 1px 1px #ffffff;
    cursor: default;
}

Something like that (although you may have to apply !important if there are cascading issues).

Sign up to request clarification or add additional context in comments.

Comments

2

The issue is that your styles are overriding the browser defaults for a disabled form element.

You need to redefine the styles by specifying :disabled pseudoclass in your CSS.

Here's a jsFiddle that shows how it works.

Comments

2
input[disabled]{
  styles here
}

1 Comment

Ah, ok, the attribute reflects the property. I thought the whole form would be disabled, but then even the pseudoclass doesn't seem to work.
0

Use the :disabled pseudoclass. This might not work in older browsers and will surely not work in IE, so you could also add a normal class to the form when disabling it.

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.