In this article I will explain with an example, how to show hide Password using EYE Icon in TextBox with jQuery.
The EYE Icon will be created using Font-Awesome Fonts and will be displayed next to TextBox.
When the EYE Icon is clicked, the TextBox will be toggled from Password TextBox to a Normal TextBox and vice versa respectively showing and hiding the Password Text.
 
 
Showing Hiding Password with EYE Icon in TextBox using jQuery
The HTML Markup consists of a Password TextBox and an HTML SPAN which has been assigned with Font-Awesome EYE Icon CSS class.
The EYE Icon HTML SPAN has been assigned with a jQuery Click event handler.
When the EYE Icon is clicked, the CSS class is toggled as well as the TextBox is toggled between a Normal TextBox and a Password TextBox by setting the Type attribute value.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
        input, input[type=password]
        {
            width: 150px;
            height: 20px;
        }
        #toggle_pwd
        {
            cursor: pointer;
        }
    </style>
</head>
<body>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
        rel="stylesheet" type="text/css" />
    <input type="password" id="txtPassword" />
    <span id="toggle_pwd" class="fa fa-fw fa-eye field_icon"></span>
    <script type="text/javascript">
        $(function () {
            $("#toggle_pwd").click(function () {
                $(this).toggleClass("fa-eye fa-eye-slash");
               var type = $(this).hasClass("fa-eye-slash") ? "text" : "password";
                $("#txtPassword").attr("type", type);
            });
        });
    </script>
</body>
</html>
 
 
Screenshot
jQuery: Show Hide Password with EYE Icon in TextBox
 
 

Browser Compatibility

The above code has been tested in the following browsers.

Internet Explorer  FireFox  Chrome  Safari  Opera 

* All browser logos displayed above are property of their respective owners.

 
 
Demo
 
 
Downloads