Textarea readOnlyProperty
Example
Set the textarea to read-only:
document.getElementById("myTextarea").readOnly = true;
Try it Yourself »
Definition and Usage
The readOnly property sets or returns whether a textarea is read-only.
In a read-only text area, the content cannot be changed, but the user can "tab" to it, or highlight and copy its content.
Browser Support
| Property | |||||
|---|---|---|---|---|---|
| readOnly | Yes | Yes | Yes | Yes | Yes |
Syntax
Set the readOnly property:
textareaObject.readOnly=true|false
Return the readOnly property:
textareaObject.readOnly
Property Values
| Value | Description |
|---|---|
| true | The textarea is read-only. |
| false | Default. The textarea can be modified. |
Technical Details
| Return Value: | A Boolean, returns true if the textarea element is read-only, otherwise false. |
More Examples
Example
Check if the textarea is read-only:
var x = document.getElementById("myTextarea").readOnly;
Try it Yourself »
Other Extensions
Textarea Object