Javascript DOM HTML Input Password defaultValue Property get

Introduction

Return the default value of a password field:

var x = document.getElementById("myPsw").defaultValue;

Click the button to alert the default value of the password field.

View in separate window

<!DOCTYPE html>
<html>
<body>

Password: <input type="password" id="myPsw" value="password123">
<p id="demo"></p>
<button type="button" onclick="myFunction()">Test</button>

<script>
function myFunction() {/*from  w w  w .  ja  va 2  s  .  c  om*/
  var x = document.getElementById("myPsw").defaultValue;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related