Textarea readOnly Property

❮ Textarea Object

Example

Set a text area to be read-only:

document.getElementById("myTextarea").readOnly = true;
Try it Yourself »

Description

The readOnly property sets or returns whether the contents of a text area should be read-only.

In a read-only text area, the content cannot be changed, but a user can tab to it, or highlight and copy the content from it.

This property reflects the HTML readonly attribute.

Tip: To prevent the user from interacting with the text area, use the disabled property instead.


Browser Support

Property
readOnly Yes Yes Yes Yes Yes

Syntax

Return the readOnly property:

textareaObject.readOnly

Set the readOnly property:

textareaObject.readOnly = true|false

Property Values

Value Description
true|false Specifies whether a text area should be read-only or not.
  • true - The text area is read-only
  • false - Default. The text area is changeable

Technical Details

Return Value: A Boolean, returns true if the text area is read-only, otherwise it returns false

More Examples

Example

Find out if a text area is read-only or not:

var x = document.getElementById("myTextarea").readOnly;
Try it Yourself »

❮ Textarea Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.