Skip to main content

show password option in asp.net using checkbox

Show password option for the Password field can be obtained by placing the checkbox and using some piece of JavaScript code to obtain this functionality. This can be done in onchange or onclick events of the checkbox. Find the example below.

ASPX code: Using onchange Event


<html>
<head runat="server">
    <title>Show password checkbox</title>
</head>
<body>
    <form id="form1" runat="server">
      <div><br />
         <asp:Label ID="Label1" runat="server" Text="User name:">
         </asp:Label><asp:TextBox ID="Uname" runat="server"></asp:TextBox>
         <br />
         <asp:Label ID="Label2" runat="server" Text="Password :"></asp:Label>
         <asp:TextBox TextMode="Password" ID="password" runat="server"></asp:TextBox>
         <input type="checkbox" onchange="document.getElementById('password').type = this.checked ? 'text' : 'password'">
            Show password
       </div>
    </form>
</body>
</html>


[OR]


ASPX code: Using onclick Event

<html>
<head runat="server">
    <title>Show password checkbox : fourthbottle</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
          Password :
          <input type="password" name="password" id="password" />
          <input type="checkbox" id="pass" onclick="showpass(this);" />
           Show Password
            <script type="text/javascript">
                function showpass(check_box) {
                    var spass = document.getElementById("password");
                    if (check_box.checked)
                        spass.setAttribute("type", "text");
                    else
                        spass.setAttribute("type", "password");
                }
           </script>
        </div>
    </form>
</body>
</html>


-Anantha Bharani Guhan

Comments

  1. Replies
    1. Great Article
      Cyber Security Projects

      projects for cse

      Networking Security Projects

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. Great Article. Thank you for sharing! Really an awesome post for every one.

    IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

    Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
    Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai

    ReplyDelete
  3. keep up the good work. this is an Assam post. this to helpful, i have reading here all post. i am impressed. thank you. this is our digital marketing training center. This is an online certificate course
    digital marketing training in bangalore | https://www.excelr.com/digital-marketing-training-in-bangalore

    ReplyDelete
  4. I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!
    data analytics course
    business analytics course
    data science courses

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. As always your articles do inspire me. Every single detail you have posted was great. ExcelR Pune Digital Marketing Course

    ReplyDelete
  7. Your information about asp is really interesting and innovative. Also I want you to share latest updates about asp. Can you update it in your website? Thanks for sharing.

    Dot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery

    ReplyDelete
  8. This article is worthy of recognition and comment. I found this material attention-grabbing and engrossing. This is well-scripted and highly informative. These views appeal to me. This is how real writing is done. Thank you.
    SAP training in Mumbai

    Data Science training in Mumbai Best

    Best Data Science training in Mumbai

    ReplyDelete
  9. This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.
    Data Science Institute in Bangalore

    ReplyDelete
  10. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.
    Data Science Certification in Bangalore

    ReplyDelete
  11. There is obviously a lot to know about this. I think you made some good points in Features also. Keep working, great job!
    Data Science Course in Bangalore

    ReplyDelete
  12. Someone Sometimes with visits your blog regularly and recommended it in my experience to read as well.
    Data Science Training in Bangalore

    ReplyDelete
  13. Just saying thanks will not just be sufficient, for the fantasti c lucidity in your writing. I will instantly grab your rss feed to stay informed of any updates.
    Data Science Training in Bangalore

    ReplyDelete
  14. The development of artificial intelligence (AI) has propelled more programming architects, information scientists, and different experts to investigate the plausibility of a vocation in machine learning. Notwithstanding, a few newcomers will in general spotlight a lot on hypothesis and insufficient on commonsense application. machine learning projects for final year In case you will succeed, you have to begin building machine learning projects in the near future.

    Projects assist you with improving your applied ML skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include projects into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Final Year Project Centers in Chennai even arrange a more significant compensation.


    Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account.

    ReplyDelete
  15. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own Blog Engine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it.
    data science training in guwahati

    ReplyDelete
  16. Really Very Infromative Post , Thanks For Sharing The Information With Us.
    Best AWS Training Institute in Hyderabad

    ReplyDelete
  17. The article unambiguously showed each of the positive and negative sides of the issue. This is indeed a thought infuriating article.
    Data Science training in Mumbai
    Data Science course in Mumbai
    SAP training in Mumbai

    ReplyDelete
  18. I'd love to thank you for the efforts you've made in composing this post. I hope the same best work out of you later on too. I wished to thank you with this particular sites! Thank you for sharing. Fantastic sites!
    Data Science Course in Bangalore

    ReplyDelete
  19. This is a great post. This post gives a truly quality information. I am certainly going to look into it. Really very helpful tips are supplied here. Thank you so much. Keep up the great works
    Data Science Training in Bangalore

    ReplyDelete
  20. Fantastic blog extremely good well enjoyed with the incredible informative content which surely activates the learners to gain the enough knowledge. Which in turn makes the readers to explore themselves and involve deeply in to the subject. Wish you to dispatch the similar content successively in future as well.

    360DigiTMG Digital Marketing Course

    ReplyDelete

Post a Comment