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