Hide/ Show Password on button click by using JavaScript and Jquery

First of all add the below code inside your <head> tag ::

 <script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
    $(function () {

        $('#btnpwd').click(function () {
            var txt = $('#btnpwd').val()
            var pwd = $('#hidepwd').val();
            if (pwd.length > 0) {
                if (txt == 'Show Password') {
                    $(this).val('Hide Password');
                    return false;
                else if (txt == 'Hide Password') {
                    $(this).val('Show Password');
                    return false;
            else {
                alert('Plese Enter Password');
                return false;


Then add code inside your <body> tag and check ::

    Enter Password :
        <asp:TextBox ID="hidepwd" runat="server" TextMode="Password"></asp:TextBox>
        <asp:TextBox ID="showpwd" runat="server"></asp:TextBox>
        <asp:Button ID="btnpwd" runat="server" Text="Show Password" />


  1. why this much of codes? Im not clear..because i found this article which does the same in few lines, and it works too..


Post a comment

Popular posts from this blog

StateCode and StatusCode Values for mostly used entities in Microsoft Dynamics CRM 2013

How to show enlarge image when mouse hover on image or link in Asp.Net(c#) using JavaScript

How to import CSV files into DataTable in C#

go to top image