Javascript DOM HTML Input Email disable and enable email field

Introduction

Disable and enable an email field:

View in separate window

<!DOCTYPE html>
<html>
<body>

E-mail: <input type="email" id="myEmail"><br><br>

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

<script>
function disableBtn() {//from w  w w.j a v a 2  s  .co m
  document.getElementById("myEmail").disabled = true;
}

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

</body>
</html>



PreviousNext

Related