Javascript DOM HTML Input Datetime Disable and enable

Introduction

Disable and enable a datetime field:

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

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="datetime" id="myDatetime"><br><br>

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

<script>
function disableBtn() {/* ww w. j a  v a  2 s. c o m*/
  document.getElementById("myDatetime").disabled = true;
}

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

</body>
</html>



PreviousNext

Related