Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Textarea readOnly property

Textarea readOnly property

Textarea Object Reference The Textarea object


Example

Set the textarea text box to read-only:

document

.

getElementById

(

"

myTextarea

"

)

.

readOnly

=

true

;

Try it »

Definition and Usage

The readOnly property sets or returns whether the 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 attribute:

textareaObject.readOnly=true|false

Return the readOnly attribute:

textareaObject.readOnly


Attribute values

Value Description
true The textarea text box is read-only.
false Default. the textarea text box can be modified

Technical Details

Return value: Boolean, returns true if the textarea element is read-only, otherwise returns false.

More examples

Example

Check whether the textarea text box is read-only:

var

x

=

document

.

getElementById

(

"

myTextarea

"

)

.

readOnly

;

Try it »


Textarea Object Reference The Textarea object