Click to See Complete Forum and Search --> : How to make a blank text field grey out


dummyagain
July 17th, 2007, 01:02 AM
I would like to know how to make a blank text field grey out? I know that when there is content, i can grey out the text field using

document.mainForm.data.disabled = true;

but how do make the whole text field grey out when there is no data in it?

Thank you.

andreasblixt
July 17th, 2007, 03:24 AM
The field always grays out (and becomes disabled) when you set its disabled property (in IE it never changes background color, maybe that's what you mean?), but if you only want it to visually gray out, you can use CSS (field.style.backgroundColor = "#ddd").

PeejAvery
July 17th, 2007, 08:27 AM
Try...

<input type="text" onfocus="this.style.background='#ffffff'" onblur="if(this.value==''){this.style.background='#dddddd'}" />