Input Datetime disabled Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Datetime

Description

The disabled property sets or gets whether a 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 datetime field should be disabled
  • true - The datetime field is disabled
  • false - Default. The datetime field is not disabled

Return Value

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

The following code shows how to disable a datetime field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="datetime" id="myDatetime"><br><br>

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

<script>
function disableBtn() {/*from   ww w .  j ava2 s  .com*/
    document.getElementById("myDatetime").disabled = true;
}

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

Related Tutorials