how to show hide password in javascript code example

Example 1: how to make a show password button

function myFunction() {
  var x = document.getElementById("*passwordbox-id*");
  if (x.type === "password") {
    x.type = "text";
  } else {
    x.type = "password";
  }
}

Example 2: password visibility toggle

function visibility3() { var x = document.getElementById('login_password'); if (x.type === 'password') { x.type = "text"; $('#eyeShow').show(); $('#eyeSlash').hide(); }else { x.type = "password"; $('#eyeShow').hide(); $('#eyeSlash').show(); } }

Tags:

Misc Example