anyanicky
asked on
CSS To Change Disabled Textbox Font Style?
Using this small example, how do I change the color/style of the font in the textbox? (IE4+) I want the text to look absolutely normal - no shadow, no weird colouring.
<style>
INPUT {font: 8pt;type=text}
.BLUE {background: #0469C3; border: none; color: white}
</style>
<form name=myform>
<input class=blue disabled>
</form>
<style>
INPUT {font: 8pt;type=text}
.BLUE {background: #0469C3; border: none; color: white}
</style>
<form name=myform>
<input class=blue disabled>
</form>
ASKER
No - not that. I know how to do that.
Let me simplify my question...
This works
<input style="border:none;color:r ed" value="this is a test">
This doesn't work
<input style="border:none;color:r ed" disabled value="this is a test">
I want to change the font color of the disabled textbox to look like the enabled one.
Let me simplify my question...
This works
<input style="border:none;color:r
This doesn't work
<input style="border:none;color:r
I want to change the font color of the disabled textbox to look like the enabled one.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Readonly proporty only works on IE, so if you don't want to change the color of your disabled textboxes you can use this crossbrowser code:
<input name="text1" type="text" value="Example1" onfocus="this.blur();retur n false;"><br>
xabi
<input name="text1" type="text" value="Example1" onfocus="this.blur();retur
xabi
I guess that disabled will always override the values you assigned to it yourself. What you however could do is to ACT to be disabled.
You should then make yourself a style which looks exactly like you want it to be. Then, you store the value of the textbox. In the onChange event of the input box you then check against the stored string. If that isn't equal, then reset the value.
Shouldn't be too hard, and you have the same effect.
You should then make yourself a style which looks exactly like you want it to be. Then, you store the value of the textbox. In the onChange event of the input box you then check against the stored string. If that isn't equal, then reset the value.
Shouldn't be too hard, and you have the same effect.
ASKER
Manolo: Exactly what I was looking for - that works great. Thankfully I don't have to worry about Netscape.
Xabi: That doesn't work - I can delete the contents of the field by selecting and rightclick deleting it.
CJ_S: I already know how to 'pretend' it is disabled. The whole point of my question was to change a disabled textbox, not make something act like one. I just thought it was very odd that I couldn't change the characteristics of a disabled textbox - apparently MS and NS have some problem with this :)
Xabi: That doesn't work - I can delete the contents of the field by selecting and rightclick deleting it.
CJ_S: I already know how to 'pretend' it is disabled. The whole point of my question was to change a disabled textbox, not make something act like one. I just thought it was very odd that I couldn't change the characteristics of a disabled textbox - apparently MS and NS have some problem with this :)
etc etc....or isn;t that what you meant?