Toggle Password Security Form Input Characters Tutorial

Published :
Author :
Adam Khoury
Learn to build a log in password security mode toggle function using simple Javascript that affects your HTML password type input field. Allow the user to change back and forth to any mode they like best for entering their passwords. <script> function togglePassword() { var upass = document.getElementById('upass'); var toggleBtn = document.getElementById('toggleBtn'); if(upass.type == "password"){ upass.type = "text"; toggleBtn.value = "Hide Password Characters"; } else { upass.type = "password"; toggleBtn.value = "Show Password Characters"; } } </script> Password: <input id="upass" type="password" name="userpass"> <input id="toggleBtn" type="button" onclick="togglePassword()" value="Show Password Characters">