Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Time readOnly property

Input Time readOnly property

Input Time Object Reference Input Time Object

Example

Set the time field to read-only:

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

Output result:

Try it »


Definition and Usage

The readOnly property sets or returns 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 disabled the attribute instead.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the readOnly property

Note: Internet Explorer or Firefox browsers do not support HTML using the type="time" attribute .


Syntax

Return the readOnly attribute:

timeObject

.readOnly

Set the readOnly attribute:

timeObject

.readOnly=true|false

Attribute values

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

    Technical Details

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

    More examples

    Example

    Check whether the time field is read-only:

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

    x

    The output is:

    true

    Try it »


    Related pages

    HTML Reference Manual: HTML readonly attribute


    Input Time Object Reference Input Time Object