Javascript DOM HTML Input Date disable and enable

Introduction

Disable and enable a date field:

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="date" id="myDate"><br><br>

<button onclick="disableBtn()">Disable Date Field</button>
<button onclick="enableBtn()">enable Date Field</button>

<script>
function disableBtn() {//from w  w w  .ja va 2  s .c om
  document.getElementById("myDate").disabled = true;
}

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

</body>
</html>



PreviousNext

Related