Javascript DOM HTML Input DatetimeLocal disabled Property set

Introduction

Disable a local datetime field:

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

Click the button to disable the local datetime field.

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="datetime-local" id="myLocalDate">
<button onclick="myFunction()">Test</button>
<script>
function myFunction() {//from www . j  a va  2s.c  o m
  document.getElementById("myLocalDate").disabled = true;
}
</script>

</body>
</html>

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

This property mirrors the HTML disabled attribute.

The disabled property accepts and returns a boolean value.

Value Description
true The local datetime field is disabled
falseDefault. The local datetime field is not disabled

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




PreviousNext

Related