"Windows 8 Style Password Reveal"
Bootstrap 3.1.0 Snippet by stickerboy

<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="text-center"> <div class="col-lg-6"> <h2>Windows 8 Style Password Reveal</h2> <div class="input-group"> <input type="password" class="form-control pwd" value="iamapassword"> <span class="input-group-btn"> <button class="btn btn-default reveal" type="button"><i class="glyphicon glyphicon-eye-open"></i></button> </span> </div> </div> </div> </div>
$(".reveal").mousedown(function() { $(".pwd").replaceWith($('.pwd').clone().attr('type', 'text')); }) .mouseup(function() { $(".pwd").replaceWith($('.pwd').clone().attr('type', 'password')); }) .mouseout(function() { $(".pwd").replaceWith($('.pwd').clone().attr('type', 'password')); });

Related: See More

Questions / Comments:

Is very simple, but don´t run in Mozilla browser

osbragon () - 2 years ago - Reply 0

The jQuery code is unnecessarily complicated. I submited a fork of this snippet with fixed JS here:

RippaGun () - 4 years ago - Reply 0

I meant to add a comment when I posted originally to say the jQ code was written like that to handle some IE bugs - there's issues with changing attributes of input elements. Yours is much cleaner if you don't need to worry about that :)

Kenny () - 4 years ago - Reply 0

you booth have the same problem, if it exist 2 or more elements it will duplicate them, so i made this one http://bootsnipp.com/snippe... to prevent that

Sr Patinhas () - 4 years ago - Reply 0

Ah excellent, thanks for sharing :)

Kenny () - 4 years ago - Reply 0

Keyboard accessibility is a miss

Dylan Grafmyre () - 4 years ago - Reply 0