Javascript Reference - HTML DOM Input Time disabled Property








The disabled property disable or enable a time field.

Browser Support

disabled Yes No No Yes Yes

Syntax

Return the disabled property.

var v = timeObject.disabled 

Set the disabled property.

timeObject.disabled=true|false

Property Values

Value Description
true|false Disable or enable a time field
  • true - The time field is disabled
  • false - Default. The time field is not disabled




Return Value

A Boolean type value, true if the time field is disabled, otherwise false.

Example

The following code shows how to get if a time field is disabled.


<!DOCTYPE html>
<html>
<body>
<input type="time" id="myTime" disabled>
<button onclick="myFunction()">test</button>
<!--from  w  ww.j  a  v a 2  s .  c  o  m-->
<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myTime").disabled;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to disable and enable a time field.


<!DOCTYPE html>
<html>
<body>
<!--  w  w w  . j a  v  a  2  s . c o  m-->
<input type="time" id="myTime"><br><br>

<button onclick="disableBtn()">Disable Time Field</button>
<button onclick="enableBtn()">Enable Time Field</button>

<script>
function disableBtn() {
    document.getElementById("myTime").disabled = true;
}
function enableBtn() {
    document.getElementById("myTime").disabled = false;
}
</script>

</body>
</html>

The code above is rendered as follows: