Input Time readOnly Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Time


The readOnly property sets or gets whether a input field should be read-only.

This property reflects the HTML readonly attribute.

Set the readOnly property with the following Values

Value Description
true|false Sets whether a time field should be read-only
  • true - The time field is read-only
  • false - Default. The time field is not read-only

Return Value

A Boolean, returns true if the time field is read-only, otherwise it returns false

The following code shows how to Set a time field to read-only:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
Time: <input type="time" id="myTime" readonly>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {/*from   ww  w . j  av  a  2 s  .c om*/
    var x = document.getElementById("myTime").readOnly;
    document.getElementById("demo").innerHTML = x;


Related Tutorials