Javascript DOM HTML Input Password Object get

Introduction

The Input Password object represents an HTML <input> element with type="password".

We can access an <input> element with type="password" via document.getElementById():

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

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

View in separate window

<!DOCTYPE html>
<html>
<body>
Password: <input type="password" id="myPsw" value="password123">
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/*from www.j av  a2 s.c o m*/
  var x = document.getElementById("myPsw").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related