Toggle show or hide password when user input

To make sure user's password are true when they are inputting, we have to add a checkbox to toggle password visibility.

2 steps to do that:

Step 1, add HTML code below

 

Show Password


When user click the radio button to check or uncheck the checkbox above, function toggleShowPassWord will be call.

Step 2, add Javascript code below:

 function toggleShowPassWord() {
   const el = document.getElementById("password");
   if (el.type === "password") {
    el.type = "text";
   } else {
    el.type = "password";
   }
  }


© 2019 4codev

Created with love by Sil.