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

 <input type="password" placeholder="Enter your password" id="password" value=""><br><br>
 <input type="checkbox">Show Password
Copy this code

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";
Copy this code

Input some texts into text box and click the radio checkbox "Show Password" below to see the result:>