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 () {
        $('#showpwd').hide();

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

    })
</script>



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

 <div>
    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" />
    </div>

Comments

Popular posts from this blog

Search data in Gridview on Textbox Key press event using JQuery in Asp.Net- C#

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

Dumps for Microsoft Dynamics CRM MB2-703 Practice Exam Questions Free

How to import CSV files into DataTable in C#

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

go to top image