Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 566 Bytes

toggle-password-visibility.md

File metadata and controls

25 lines (20 loc) · 566 Bytes

How to toggle password visibility

All you need to do is to change the type property of the element from password to text back and forth:

<input
    type="password"
    class="input_password"
    oninput="onPasswordChange(this)">
function togglePassword() {
    const password = document.querySelector('.input_password');

    if(password.type === 'password') {
        password.type = 'text';
    } else {
        password.type = 'password';
    }
}

References: