Visible Password

0

I am building a login in asp.net and I want that when clicking the checkbox to show the password it is shown.

Design asp page

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="Titulo" class="divtitulo">
<asp:Label ID="lbl_administracao" runat="server" Text="Login Administração"></asp:Label>
</div>
<br />
 <div id="Login" class="divlogin" runat="server">
      <div id="wrapper">
<asp:Label ID="lbl_utilizador" runat="server" Text="Nome Utilizador:"></asp:Label>
          <br />
<asp:TextBox ID="txt_utilizador" runat="server" Width="230px"></asp:TextBox>

<br />

<asp:Label ID="lbl_password" runat="server" Text="Palavra-Passe:"></asp:Label>
          <br />
<asp:TextBox ID="txt_password" TextMode="Password" runat="server" Width="230px"></asp:TextBox>

<br />

<asp:CheckBox ID="chbox_mostrarpassword" runat="server" Text="Mostrar Palavra-Passe" />

<br />

<asp:Button ID="bt_login" runat="server" Text="Iniciar Sessão" />
          </div>
  </div>

    
asked by anonymous 04.05.2018 / 13:00

1 answer

0

Try to put in the checkbox's onchange event

<asp:CheckBox ID="chbox_mostrarpassword" runat="server"
 Text="Mostrar Palavra-Passe" 
 onchange="document.getElementById('lbl_password').type = this.checked ? 'text' : 'password'" />
  

References

Add Option to Show password

    
04.05.2018 / 13:23