Input Email readOnly Attribute

Definition and Usage

readOnly Set or return whether the email field should be read-only.

You cannot modify a read-only field. However, users can select it, highlight it, and copy text from it.

This property reflects the HTML readonly attribute.

Tip:To prevent users from interacting with the field, use disabled attribute.

See also:

HTML Reference Manual:HTML <input> readonly Attribute

Example

Example 1

Set the email field to read-only:

document.getElementById("myEmail").readOnly = true;

Try it yourself

Example 2

Check if the email field is read-only:

var x = document.getElementById("myEmail").readOnly;

Try it yourself

Syntax

Return the readOnly property:

emailObject.readOnly

Set the readOnly property:

emailObject.readOnly = true|false

Attribute value

Value Description
true|false

Specify whether the email field should be read-only.

  • true - The email field is read-only
  • false - Default. The email field is not read-only.

Technical Details

Return Value: Boolean value, returns if the email field is read-only true; otherwise return false.

Browser Support

The numbers in the table indicate the first browser version that fully supports this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support