2

Q: Is it possible to change the font of a disabled input box?

In IE8/9 it shows up as light gray and is barely readable. Chrome and Firefox are fine (of course). I have tried to set the css style to color: #000 !important but it's still very light gray.

<input class="TextBoxAsLabel" data-val="true" data-val-number="blah" disabled="disabled" id="Total" name="XTotal" type="text" value="$0.00" />
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
genxgeek
  • 13,109
  • 38
  • 135
  • 217

2 Answers2

3

There is no way to do it - what you can do instead though is change the input to readonly:

<input class="TextBoxAsLabel" data-val="true" data-val-number="blah" readonly="readonly" id="Total" name="XTotal" type="text" value="$0.00" />

This will give you the disabled functionality but preserve styling :)

See this post for more details: How to change font-color for disabled input?

Hope This Helps.

Community
  • 1
  • 1
sdo
  • 652
  • 3
  • 13
  • 2
    Just keep in mind that `readonly` inputs are sent to the server. So, if the value is set to something, and you set it to `readonly`, the server will receive the set value (even if it is empty). – Kevin Peno Nov 10 '11 at 01:29
  • Unfortunately `readonly` also allows the user to put the cursor in it, which makes it look editable, which is misleading. To make matters worse, if you put the cursor in the field and then hit backspace to delete the contents, the browser will navigate to the previous page...nasty! – Mog0 Oct 24 '14 at 16:27
2

try this

input:disabled {
  color : #000 !important;
}
Mak
  • 19,913
  • 5
  • 26
  • 32
  • 1
    While this is best for forward compatibility, it will not and does not work in IE. It may also still not work in Opera as well. – Kevin Peno Nov 10 '11 at 01:28