Javascript DOM HTML Input Datetime disabled Property set

Introduction

Disable a datetime field:

document.getElementById("myDatetime").disabled = true;

Click the button to disable the datetime field.

input elements with type="datetime" is supported by Safari.

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="datetime" id="myDatetime">
<button onclick="myFunction()">Test</button>
<script>
function myFunction() {/*from   w  w w .  j a v a  2  s. c  o  m*/
  document.getElementById("myDatetime").disabled = true;
}
</script>

</body>
</html>

The disabled property sets or gets whether a datetime field should be disabled, or not.

This property mirrors the HTML disabled attribute.

The <input type="datetime"> element is supported by Safari.

Property Values

Value Description
true The datetime field is disabled
false Default. The datetime field is not disabled

The disabled property returns true if the datetime field is disabled, otherwise it returns false.




PreviousNext

Related