Get Input Password Field - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Password

Introduction

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

You can access an <input> element with type="password" by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Password: <input type="password" id="myPsw" value="psw123">

<button onclick="myFunction()">get the password of the password field</button>

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

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

</body>
</html>

Related Tutorials