Input Email readOnly
Property
Example
Set the email field to read-only:
document.getElementById("myEmail").readOnly = true;
Output result:
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, its content can be copied.
This property reflects the HTML readonly
attribute.
Tip: To ensure the accuracy of form data, you can use the disabled property instead.
Browser Support
All major browsers support the readOnly
property.
Note: Internet Explorer 9 (and earlier versions) or Safari do not support the HTML <input>
element with type="email"
.
Syntax
Return the readOnly
property:
Set the readOnly
property:
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: | Boolean, returns true if the email field is read-only, otherwise returns false. | | --- | --- |
More Examples
Example
Check if the email field is read-only:
var x = document.getElementById("myEmail").readOnly;
true
Related Pages
HTML Reference: HTML <input> readonly Attribute