Since you tagged your question as javascript
, here is my advice for IE : include an ie-only script with an ie-triggering html comments, that adds a ie-disabled
class to every disabled input. If the status of inputs can change after the initial page load, add a timed observer to your page that sets the class properly.
input[disabled], input.ie-disabled
{
background-color:#FFFBF0;
color: #28B51D;
}
javascript file, included with conditional comment:
function checkDisabled() {
var inputs = document.getElementsByTagName('INPUT');
for(var i=0, l=inputs.length; i<l; i++) {
if(inputs[i].disabled) {
if(inputs[i].className.indexOf('ie-disabled')==-1)
inputs[i].className = inputs[i].className+' ie-disabled';
} else {
inputs[i].className = inputs[i].className.replace('ie-disabled', '');
}
}
}
setInterval(checkDisabled, 1000); // check every second
Here is a test (for IE). Note that the color css attribute is ignored by IE for disabled inputs. If you really need a green text, use readonly
instead of disabled
.