-
Password Hide and Show
HTML
CSS
JavaScript
Password Show / Hide
Show
body { margin: 0; font-family: Arial, sans-serif; background: #000000; color: white; } .wrapper { max-width: 600px; margin: 40px auto; padding: 20px; } h2 { text-align: center; margin-bottom: 40px; color: #38bdf8; font-size: 30px; } /* Preview Box */ .preview { background: #1e293b; padding: 40px; border-radius: 12px; text-align: center; margin-bottom: 20px; border: #38bdf8 3px solid; } .input-box { position: relative; display: inline-block; } input { padding: 12px 40px 12px 12px; font-size: 16px; border-radius: 8px; border: none; outline: none; width:380px; border: 2px solid #1a7f84; } input:focus { box-shadow: 0 0 8px #38bdf8, 0 0 16px #38bdf8, 0 0 24px #0ea5e9; } .toggle { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); cursor: pointer; color: #555; font-size: 14px; }
function togglePassword() { const password = document.getElementById("password"); const toggle = document.querySelector(".toggle"); if (password.type === "password") { password.type = "text"; toggle.textContent = "Hide"; } else { password.type = "password"; toggle.textContent = "Show"; } }
Live Preview