Forum Moderators: not2easy

Message Too Old, No Replies

Disable input box with CSS

inline with pure CSS, no javascript

         

mattglet

5:23 pm on Nov 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it possible to disable an input box with pure CSS?

I need to do this javascript equivalent:

document.forms['myform'].myinput.disabled = true;

Can it be done inline?

Lance

6:07 pm on Nov 8, 2004 (gmt 0)

10+ Year Member



Disabled is an attribute, not a style. I don't believe there is any way to disable a control with css. That said, you can hide (VISIBILITY: hidden) or remove (DISPLAY: none) a control using css though.

encyclo

6:17 pm on Nov 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you want it to be temporarily or permanently disabled? If it's the former, then you've got no choice other than to use Javascript: CSS is for adding styles, not functionality. If the latter, you can simply add the appropriate HTML attribute:

<input type="text" disabled="disabled">

mattglet

6:42 pm on Nov 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am aware of the difference between attributes and styles, just didn't know if CSS had some trick that I could use. Thanks for the confirmation.

DrDoc

7:40 pm on Nov 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am aware of the difference between attributes and styles

Well, that's the answer to your question. CSS only controls look and feel with regards to layout, but has nothing to do with functionality of an element.

mattglet

8:11 pm on Nov 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Agreed. My only partial knowledge of what CSS can actually accomplish led me to the question.

Thanks again.