Javascript DOM HTML Input Month disable and enable

Introduction

Disable and enable a month field:

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="month" id="myMonth"><br><br>

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

<script>
function disableBtn() {/* w  ww .j  a  va 2 s . co  m*/
  document.getElementById("myMonth").disabled = true;
}
function enableBtn() {
  document.getElementById("myMonth").disabled = false;
}
</script>

</body>
</html>



PreviousNext

Related