Visible password

Asked

Viewed 94 times

0

I am building a login in Asp.net and I want to click on the checkbox to show the password to be shown.

Design page Asp

<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>

  • No the question is different! I want it when the checkbox is checked and not only when you are clicking

  • I get it @Jose, but this question does what you need, which is to change the type of input, the rest is just make some small change in the code, the goal is the same, only it is not a reply of type copy and paste, but understanding is simple to do in your code

  • that didn’t work. Is it because it is an Asp.net with a Masterpage?

1 answer

0

Try putting in the checkbox 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

  • how can I do this on Client Side so I don’t have to go to the server to go back?

  • this is already on the site client, is a javascript function

  • change runat=server to runat=client

Browser other questions tagged

You are not signed in. Login or sign up in order to post.