Input Email readOnlyProperty

Input Email 对象参考手册Input Email Object

Example

Set the email field to read-only:

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

Output:


Try it Yourself »

Definition and Usage

The readOnly property is used to set or return whether the email field is read-only.

A read-only field cannot be modified. However, the content of the field can be copied.

This property reflects the HTML readonly attribute.

Tip:To ensure the accuracy of form data, you can usedisabledproperty instead.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the readOnly property.

Note:Internet Explorer 9 (and earlier IE versions), or Safari browser, do not support HTML <input> elements with type="email".


Syntax

Return the readOnly property:

emailObject.readOnly

Set the readOnly property:

emailObject.readOnly=true|false

Property Values

Value Description
true|false Describes whether the email field is read-only
  • true - The email field is read-only
  • false - Default. The email field is not read-only

Technical Details

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


More Examples

Example

Check whether the email field is read-only:

var x = document.getElementById("myEmail").readOnly;
xThe output result is:
true

Try it Yourself »


Related Pages

HTML Reference Manual:HTML <input> readonly Attribute


Input Email 对象参考手册Input Email Object Other Extensions