Javascript DOM HTML Input Password value Property get

Introduction

Get the value attribute of a password field:

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

Click the button to display the password of the password field.

View in separate window

<!DOCTYPE html>
<html>
<body>

Password: <input type="password" id="myPsw" value="mypwd345">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//  w w w .  j a va 2  s.  c o m
  var x = document.getElementById("myPsw").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The value property sets or gets the value attribute of a password field.

The value property accepts and returns a String type value.




PreviousNext

Related