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

<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')); });

Similar snippets: See More


Dylan Grafmyre 2014-04-14 23:27:50
    Keyboard accessibility is a miss
RippaGun 2014-05-02 08:55:09
    The jQuery code is unnecessarily complicated. I submited a fork of this snippet with fixed JS here:
Kenny 2014-06-05 10:53:23
    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 :)
Sr Patinhas 2014-08-01 14:53:21
    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
Kenny 2014-08-01 18:06:05
    Ah excellent, thanks for sharing :)
osbragon 2016-07-19 16:24:35
    Is very simple, but donĀ“t run in Mozilla browser

Commenting will be back soon.