How to create option to see password typed in form [duplicate]

1

I'm creating a page to log in and access a site's administrative area. All this is being done in PHP , however I'm trying to create a stop that I saw in some sites that is the option to see the password that was entered.

I would like to know what technology is used to create this option and if possible how to create it?

    
asked by anonymous 23.01.2017 / 02:18

2 answers

1

A simple code to hide and display the password:

function mostrarSenha() {
  var tipo = document.getElementById("senha");
  if(tipo.type == "password"){
      tipo.type = "text";
  }else{
      tipo.type = "password";
  }
}
<input id="senha" type="password" value="teste">
<button onclick="mostrarSenha()">Mostrar Senha</button>
    
23.01.2017 / 02:29
0

See if it helps you this way:

  $(document).ready(function() {
      $("#showHide").click(function() {
        if ($(".password").attr("type") == "password") {
          $(".password").attr("type", "text");

        } else {
          $(".password").attr("type", "password");
        }
      });
    });
#showHide {
      width: 15px;
      height: 15px;
      float: left;
}
#showHideLabel {
      float: left;
      padding-left: 5px;
}
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><table><tr><td>Password:</td><td><inputtype="password" name="password" class="password" size="25">
        </td>
      </tr>
      <tr>
        <td></td>
        <td>
          <input type="checkbox" id="showHide" />
          <label for="showHide" id="showHideLabel">Show Password</label>
        </td>
      </tr>
    </table>
    
23.01.2017 / 02:31