Show/hide password onClick

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mihaadzic
User
Posts: 53

Show/hide password onClick

Post by mihaadzic »

Is there a way to do this?

I would like to add a button on which a user can click to display the password that is hidden ***** by default.

Thank you.


digitalphotoworld
User
Posts: 416
Location: Nürnberg/Germany

Post by digitalphotoworld »

This is a working example for login.php
Put the following jQuery-Code in Clients-Scripts -> Other -> Login Page -> Startup Script

$(document).ready(function() {

$( ' <a id="toggle" class="btn btn-xs btn-info" href="#">Toggle</a>' ).insertAfter( "#password" );

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

} else {
  $("#password").attr("type", "password");
}

});
});


Adam
User
Posts: 480

Post by Adam »

This is a nicer approach... (if you add it to the global startup event then it will work for any page with the password field):

$('<i id="pwstd" href="#" style="margin-left: 5px;" class="glyphicon glyphicon-eye-open"></i>').insertAfter('#password');
$('#pwstd').hover(function() {
$('#password').attr('type', 'text');
}, function() {
$('#password').attr('type', 'password');
});


Post Reply