Created
May 7, 2015 03:59
-
-
Save dkrnl/9fdd1a93c9a83e889098 to your computer and use it in GitHub Desktop.
Input Password Type Toggle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="input-group"> | |
<input class="form-control" id="id_password" name="password" required="required" type="password" value="" /> | |
<label class="input-group-addon" for="id_password" id="id_password_toggle"> | |
<i class="fa fa-eye-slash"></i> | |
</label> | |
</div> | |
<script> | |
jQuery(function($) { | |
var input = $("#id_password"); | |
$("#id_password_toggle").on("mousedown", function() { | |
input.attr("type", "text"); | |
$(".fa", this).attr("class", "fa fa-eye"); | |
}).on("mouseup mouseleave", function() { | |
input.attr("type", "password"); | |
$(".fa", this).attr("class", "fa fa-eye-slash"); | |
}).attr("unselectable", "on").css("user-select", "none").on("selectstart", false); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment