Input Password value Property - Change the value of the password field: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Password

Description

Input Password value Property - Change the value of the password field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form>
Password: <input type="password" id="myPsw">
</form>/*from w ww. ja  va2s.  c  om*/

<button onclick="display()">Display value</button>
<button onclick="change()">Change value</button>

<script>
function display() {
    var x = document.getElementById("myPsw").value;
    console.log("The value of the password field is: " + x);
}

function change() {
    var x = document.getElementById("myPsw").value = "NewPassword123";
    console.log("The value was changed to: " + x);
}
</script>

</body>
</html>

Related Tutorials