Javascript DOM HTML Input DatetimeLocal disable and enable a local datetime field

Introduction

Disable and enable a local datetime field:

View 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() {/*from   ww w .  jav a2  s  .c  o  m*/
  document.getElementById("myLocalDate").disabled = true;
}

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

</body>
</html>



PreviousNext

Related