Javascript DOM HTML Input Password disable and enable

Introduction

Disable and enable a password field:

View in separate window

<!DOCTYPE html>
<html>
<body>

<form>
Username: <input type="text" id="usrname"><br>
Password: <input type="password" id="myPsw">
</form><br>

<button onclick="disablePsw()">Disable Password field</button>
<button onclick="enablePsw()">enable Password field</button>

<script>
function disablePsw() {// ww w  .  j a v a 2 s . c o  m
  document.getElementById("myPsw").disabled = true;
}
function enablePsw() {
  document.getElementById("myPsw").disabled = false;
}
</script>

</body>
</html>



PreviousNext

Related