Skip to content

Instantly share code, notes, and snippets.

@ursuleacv
Created November 20, 2012 20:15
Show Gist options
  • Save ursuleacv/4120746 to your computer and use it in GitHub Desktop.
Save ursuleacv/4120746 to your computer and use it in GitHub Desktop.
A CodePen by ursuleacv. Unmask Password On Focus - Not compatible in IE, will post a fix soon.
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
</head>
<body>
<div>
<h1>Passwords<span> unmask on focus</span></h1>
<form>
<input type="password" value="" class="password" placeholder="Enter Password" id="password" />
<input type="password" value="" class="password" placeholder="Confirm Password" id="confirm" />
</form>
</div>
</body>
</html>
$(function() {
$('.password').focus(function() {
$('.password').prop('type', 'input');
});
$('.password').blur(function() {
$('.password').prop('type', 'password');
});
$('.password').keyup(function() {
var password = $('#password').val();
var confirm = $('#confirm').val();
if (password == confirm) {
$('.password').css('background', 'url(http://beeks.me/images/codepen/password.png) no-repeat 270px 9px #e5e5e5');
} else {
$('.password').css('background', 'url(http://beeks.me/images/codepen/password.png) no-repeat 270px -35px #e5e5e5');
}
});
});
body {
background: #eee;
font-family: "Open Sans", Arial, Helvetica;
margin-top: 50px;
font-size: 12px;
}
div {
width: 400px;
margin: 0 auto;
text-align: center;
}
h1 {
font-size: 30px;
color: #969696;
text-shadow: 1px 1px 0px #fff;
font-weight: 100;
}
h1 span {
font-size: 14px;
color: #c8c8c8;
}
.password {
border: 1px solid #cccccc;
border-bottom-color: #fff;
border-right-color: #fff;
border-radius: 3px;
padding: 10px;
width: 280px;
margin-bottom: 5px;
background: #e5e5e5;
color: #555;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment