Site Loader
Get a Quote

Hide/show Password

Hide/show Password on click

Hide/show Password on click: Hi Readers, today we are going to describe how one can easily reveal Password, i.e., Hide/show Password on click.

Normally when we register or log in to any site there is a password field which shows dot or asterisk only for security reasons but for most of the users faces some trouble to remember the password. In that cases,

The main logic behind this is to simply change the Password type input field to text type field as soon as the click event of button or checkbox is performed. Here in our program, we use a checkbox.


Password: Show Password


Hide /show Toggle Password Visibility

Step 1) Add HTML:

Example

<!– Password field –>
Password: <inputtype=”password”value=”FakePSW”id=”myInput”><!– An element to toggle between password visibility –>
<input type=”checkbox”onclick=”myFunction()”>Show Password

Step 2) Add JavaScript:

Example

<script>

function myFunction() {
var x = document.getElementById(“myInput”);
if (x.type ===”password”) {
x.type = “text”;
} else {
x.type =”password”;
}
</script>

 Feedback :- I hope you would like this topic n Hide/show Password on click button using JavaScript on jquery

Post Author: TechieFlair