The disabled
property enables or disables a datetime field.
disabled |
No | No | No | No | No |
Return the disabled property.
var v = datetimeObject.disabled
Set the disabled property.
datetimeObject.disabled=true|false
Value | Description |
---|---|
true|false | Disable or enable a datetime field
|
A Boolean type value returns true if the datetime field is disabled, otherwise returns false.
The following code shows how to get if a datetime field is disabled.
<!DOCTYPE html>
<html>
<body>
<!--from www . j ava 2 s . c o m-->
<input type="datetime" id="myDatetime" disabled>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myDatetime").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 datetime field.
<!DOCTYPE html>
<html>
<body>
<!-- w w w. j av a2 s . c om-->
<input type="datetime" id="myDatetime"><br><br>
<button onclick="disableBtn()">Disable Datetime Field</button>
<button onclick="enableBtn()">Enable Datetime Field</button>
<script>
function disableBtn() {
document.getElementById("myDatetime").disabled = true;
}
function enableBtn() {
document.getElementById("myDatetime").disabled = false;
}
</script>
</body>
</html>
The code above is rendered as follows: