Javascript Magic 4 - Password Visibility Toggle with JavaScript

Publié le: 09 août 2023
sur la chaîne: The Codebrow
61
1

There's an HTML body tag containing a div element.
Inside the div, there are two input elements:
One is of type "password" with the id "pwd". This is where the user can enter their password.
The other is of type "checkbox" with the id "chk". This checkbox allows the user to toggle the visibility of the password.

The JavaScript code is placed inside a script tag.
It starts by getting references to the password input element and the checkbox input element using document.getElementById().
An event handler is attached to the checkbox's onchange event. This means that when the user interacts with the checkbox (checks or unchecks it), the code inside the event handler will run.

Inside the event handler function, it checks the checked property of the checkbox input element. If the checkbox is checked (check.checked is true), it sets the type attribute of the password input element to "text", making the password characters visible. If the checkbox is unchecked (check.checked is false), it sets the type attribute back to "password", hiding the password characters.


Sur cette page du site, vous pouvez voir la vidéo en ligne Javascript Magic 4 - Password Visibility Toggle with JavaScript durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur The Codebrow 09 août 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 61 fois et il a aimé 1 téléspectateurs. Bon visionnage!