Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling Textarea from CSS

Tags:

In order to disable a textarea (or any other input element), you can:

  • In HTML, you can write: <textarea id='mytextarea' disabled></textarea>

  • From jQuery, you can: $("#mytextarea").attr("disabled","disabled");

  • CSS? Is it possible to disable the textarea with CSS?

like image 569
bArmageddon Avatar asked Mar 28 '12 15:03

bArmageddon


People also ask

How do I turn off text area?

When present, it specifies that the text area should be disabled. A disabled text area is unusable and the text is not selectable (cannot be copied). The disabled attribute can be set to keep a user from using the text area until some other condition has been met (like selecting a checkbox, etc.).

How do I enable and disable textarea?

Easiest solution, add an id, and use getElementById. Almost. Remove the quotes around "false" to make the argument a boolean and not a string, and you'll have it.

How do I use disable in CSS?

The :disabled CSS pseudo-class represents any disabled element. An element is disabled if it can't be activated (selected, clicked on, typed into, etc.) or accept focus. The element also has an enabled state, in which it can be activated or accept focus.

How do I restrict textarea size in HTML?

To disable the resizing (drag thumb) just use resize: none; . To restrict size max(min)-width and height should do the trick.


1 Answers

You can make a textarea appear disabled, but you can't actually disable it.

Using JavaScript, all you're really doing is modifying the same DOM attribute that's set by the HTML disabled attribute, so using HTML and JavaScript you're essentially doing the same thing. CSS, however, is completely out of this picture, as it doesn't do DOM manipulation of any sort — all it controls is the appearance (visual or otherwise) of an element, not its behavior.

like image 137
BoltClock Avatar answered Oct 15 '22 12:10

BoltClock