Hide and Show Password using Eye Icon with JQuery Example

Introduction

Have you ever been frustrated with password fields that hide your password as you type? Wouldn’t it be great if you could easily toggle between hiding and showing your password with just a click of a button? Well, you’re in luck! In this blog post, we’ll explore how to implement a hide and show password feature using JQuery and an eye icon.

Why Hide and Show Password?

Password security is crucial for protecting our online accounts. However, entering a password without being able to see it can be inconvenient and prone to errors. By implementing a hide and show password feature, users can easily verify the accuracy of their passwords before submitting them, enhancing the overall user experience.

Getting Started

index.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Show Hide Password with EYE Icon in Input - Wizbrand</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" />
    <style type="text/css">
        h4{
          text-align:center;
        }
        .container form{
          width:250px;
          margin:20px auto;
        }
        i{
          cursor:pointer;
        }
    </style>
</head>
<body>
  
<div class="container">
  <h4>JQuery: Show Hide Password with EYE Icon in Input - Wizbrand</h4>
  <form class="form-inline">
    
      <label class="sr-only" for="password">Password</label>
      <div class="input-group mb-3">
          <span class="input-group-text" id="basic-addon1"><i class="fa fa-eye-slash" id="eye"></i></span>
          <input type="password" class="form-control" placeholder="Password" aria-label="Password" aria-describedby="basic-addon1" id="password">
        </div>
  
    </form>
</div>
  
</body>
  
<script type="text/javascript">
      
    $(function(){
    
      $('#eye').click(function(){
             
            if($(this).hasClass('fa-eye-slash')){
                 
              $(this).removeClass('fa-eye-slash');
                
              $(this).addClass('fa-eye');
                
              $('#password').attr('type','text');
                  
            }else{
               
              $(this).removeClass('fa-eye');
                
              $(this).addClass('fa-eye-slash');  
               
              $('#password').attr('type','password');
            }
        });
    }); 
  
</script>
</html>

Output:-

Related Posts

The Complete SEO Playbook for AI Guest Post Generation and Publishing

Introduction Search engine optimization relies heavily on authority, relevance, and trust. While search algorithms continually evolve, securing high-quality backlinks through strategic content placement remains a foundational ranking…

Read More

Top Digital Marketing Workflow Management Tools for Agencies

Introduction Managing a modern digital marketing stack often feels like juggling dozens of disconnected software subscriptions. Marketing managers, agency owners, and SEO specialists frequently find themselves jumping…

Read More

AI Prompt Management Tools: From Basic Prompts to High-Value Digital Assets

Generative artificial intelligence has fundamentally altered how modern enterprises, creative teams, and technical engineers operate. However, as organizations increase their reliance on large language models (LLMs), a…

Read More

Automated Payment Management Software for Modern Enterprises

Finance operations form the backbone of every enterprise, yet many organizations still struggle with fragmented billing tools, delayed collections, and manual reconciliation. Relying on spreadsheets and disconnected…

Read More

The Complete Guide to Choosing the Best Vehicle Rental Management Software

INTRODUCTION Managing a vehicle rental business manually through spreadsheets, paper ledgers, or messaging apps creates significant operational friction. Rental agency owners face recurring challenges including double bookings,…

Read More

The Ultimate Guide to Predictive Alerts and Data Observability

Introduction In modern data-driven enterprises, data pipelines serve as the central circulatory system of business intelligence, operational analytics, machine learning platforms, and executive decision-making. However, as data…

Read More
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x