The disabled
property disable or enable a time field.
disabled |
Yes | No | No | Yes | Yes |
Return the disabled property.
var v = timeObject.disabled
Set the disabled property.
timeObject.disabled=true|false
Value | Description |
---|---|
true|false | Disable or enable a time field
|
A Boolean type value, true if the time field is disabled, otherwise false.
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:
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: