Input DatetimeLocal disabled Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Datetime Local

Description

The disabled property sets or gets whether a local datetime field is disabled.

This property reflects the HTML disabled attribute.

Set the disabled property with the following Values

Value Description
true|false Sets whether a local datetime field should be disabled
  • true - The local datetime field is disabled
  • false - Default. The local datetime field is not disabled

Return Value

A Boolean, returns true if the local datetime field is disabled, otherwise it returns false

The following code shows how to disable a local datetime field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<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() {/* w ww  .j av a2s  .co  m*/
    document.getElementById("myLocalDate").disabled = true;
}

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

</body>
</html>

Related Tutorials