RobertDBroley's avatar

Show Password Button

Does anyone know how to implement the show password like on Twitter please?

0 likes
5 replies
RobinMalfait's avatar

change the type from type="password" to type="text" using jquery or something.

2 likes
toniperic's avatar

When you click the "Show password" button, just make sure the target input element type attribute is changed from "password" to "text".

So if you had a "Show password" button, and an input where user enters his password, like so:

<input type="password">

what you would do (with Javascript) is just change the type from "password" to "text".

1 like
RobertDBroley's avatar

Would anyone know how I could do it with a check box and some jquery please?

AhmedHamed's avatar

Here's an example using a checkbox:

<script>
$(document).ready(function(){
    $('#checkbox').on('change', function(){
        $('#password').attr('type',$('#checkbox').prop('checked')==true?"text":"password"); 
    });
});
</script>
<input type="password" id="password"> 
<input type="checkbox" id="checkbox">Show Password
4 likes

Please or to participate in this conversation.