How to disable a text area?
How to disable a text area?
123
21-Jul-2023
Updated on 21-Jul-2023
Aryan Kumar
21-Jul-2023There are two ways to disable a text area in HTML:
disabled
attributeThe
disabled
attribute is a boolean attribute. When present, it specifies that the element should be disabled. A disabled element cannot be interacted with by the user.To disable a text area using the
disabled
attribute, add thedisabled
attribute to thetextarea
element and set its value totrue
.HTML
disabled
propertyThe JavaScript
disabled
property is a boolean property. It can be used to set or get the disabled state of an element.To disable a text area using JavaScript, you can use the following code:
JavaScript
This code will disable the text area with the ID
textarea
.Here are some additional things to keep in mind when disabling text areas: