Input Time readOnly
Attribute
Example
Set the time field to read-only:
document.getElementById("myTime").readOnly = true;
Output result:
Definition and Usage
The readOnly
attribute is used to set or return whether the time field is read-only.
A read-only field cannot be modified. However, its content can be copied.
This attribute reflects the HTML readonly
attribute.
Tip: To ensure the accuracy of form data, you can use the disabled attribute instead.
Browser Support
All major browsers support the readOnly
attribute.
Note: Internet Explorer or Firefox browsers do not support the HTML <input>
element with the type="time"
attribute.
Syntax
Return the readOnly
attribute:
Set the readOnly
attribute:
Attribute Values
Value | Description |
---|---|
true|false | Describes whether the time field is read-only. <br> true - The time field is read-only. <br> false - Default. The time field is not read-only. |
Technical Details
| Return Value: | Boolean, returns true if the time field is read-only, otherwise returns false. | | --- | --- |
More Examples
Example
Check if the time field is read-only:
var x = document.getElementById("myTime").readOnly;
true
Related Pages
HTML Reference: HTML <input> readonly Attribute