<div class="password">
<input type="password" class="password-input" maxlength="9" />
<div class="check">
<svg>
<use xlink:href="#check" />
</svg>
</div>
<div class="lock">
<svg>
<use xlink:href="#lock" />
</svg>
</div>
<div class="indicator"></div>
</div>
<!-- SVG -->
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 180 30" id="lock">
<path d="M162,29a3,3,0,0,1-3-3V14a3,3,0,0,1,3-3h14a3,3,0,0,1,3,3V26a3,3,0,0,1-3,3H1M162.5,11V4a3,3,0,0,1,3-3h7a3,3,0,0,1,3,3v7"/>
</symbol>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 15" id="check">
<polyline points="1 8.53 6.33 14 19 1"/>
</symbol>
</svg>
<!--- ## DRIBBBLE + TWITTER ############# -->
<div class="socials">
<a class="dribbble" href="https://dribbble.com/shots/10079320-Password-validate-animation" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 32 32"><path fill-rule="evenodd" clip-rule="evenodd" fill="black" d="M16 0C7.16703 0 0 7.16703 0 16C0 24.833 7.16703 32 16 32C24.8156 32 32 24.833 32 16C32 7.16703 24.8156 0 16 0ZM26.5683 7.37527C28.4772 9.70065 29.6226 12.6681 29.6573 15.8785C29.2061 15.7918 24.6941 14.872 20.1475 15.4447C20.0434 15.2191 19.9566 14.9761 19.8525 14.7332C19.5748 14.0738 19.2625 13.397 18.9501 12.7549C23.9826 10.7072 26.2733 7.75705 26.5683 7.37527ZM16 2.36009C19.4707 2.36009 22.6464 3.66161 25.0586 5.7961C24.8156 6.14317 22.7505 8.90239 17.8915 10.7245C15.6529 6.61171 13.1714 3.24512 12.7896 2.72451C13.8134 2.48156 14.8894 2.36009 16 2.36009ZM10.1866 3.64425C10.551 4.13015 12.9805 7.5141 15.2538 11.5401C8.86768 13.2408 3.22777 13.2061 2.62039 13.2061C3.50542 8.9718 6.36876 5.44902 10.1866 3.64425ZM2.32538 16.0174C2.32538 15.8785 2.32538 15.7397 2.32538 15.6009C2.9154 15.6182 9.54447 15.705 16.3644 13.6573C16.7636 14.4208 17.128 15.2017 17.4751 15.9826C17.3015 16.0347 17.1106 16.0868 16.9371 16.1388C9.89154 18.4121 6.14317 24.6247 5.8308 25.1453C3.6616 22.7332 2.32538 19.5228 2.32538 16.0174ZM16 29.6746C12.8416 29.6746 9.92625 28.5987 7.61822 26.7939C7.86117 26.2907 10.6377 20.9458 18.3427 18.256C18.3774 18.2386 18.3948 18.2386 18.4295 18.2213C20.3557 23.2017 21.1367 27.3839 21.3449 28.5813C19.6963 29.2928 17.8915 29.6746 16 29.6746ZM23.6182 27.3319C23.4794 26.4989 22.7505 22.5076 20.9631 17.5965C25.2495 16.9197 28.9978 18.0304 29.4664 18.1866C28.8764 21.987 26.6898 25.2668 23.6182 27.3319Z" fill="#EA4C89"></path></svg></a>
<a class="twitter" href="https://twitter.com/MilanRaring" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 72 72"><path fill="black" d="M67.812 16.141a26.246 26.246 0 0 1-7.519 2.06 13.134 13.134 0 0 0 5.756-7.244 26.127 26.127 0 0 1-8.313 3.176A13.075 13.075 0 0 0 48.182 10c-7.229 0-13.092 5.861-13.092 13.093 0 1.026.118 2.021.338 2.981-10.885-.548-20.528-5.757-26.987-13.679a13.048 13.048 0 0 0-1.771 6.581c0 4.542 2.312 8.551 5.824 10.898a13.048 13.048 0 0 1-5.93-1.638c-.002.055-.002.11-.002.162 0 6.345 4.513 11.638 10.504 12.84a13.177 13.177 0 0 1-3.449.457c-.846 0-1.667-.078-2.465-.231 1.667 5.2 6.499 8.986 12.23 9.09a26.276 26.276 0 0 1-16.26 5.606A26.21 26.21 0 0 1 4 55.976a37.036 37.036 0 0 0 20.067 5.882c24.083 0 37.251-19.949 37.251-37.249 0-.566-.014-1.134-.039-1.694a26.597 26.597 0 0 0 6.533-6.774z"></path></svg></a>
</div>
.password {
--svg-color: #808390;
--text-color: #414856;
--weak-color: #F04545;
--medium-color: #FFA850;
--strong-color: #47C796;
--width: 180px;
--height: 30px;
display: flex;
justify-content: center;
align-items: center;
position: relative;
input {
background: none;
border: 0;
outline: none;
width: 22px;
height: var(--height);
z-index: 1;
position: relative;
appearance: none;
transition: all .6s ease-out;
cursor: pointer;
color: var(--text-color);
font: 400 14px 'Poppins', sans-serif;
}
.check {
display: none;
width: var(--height);
height: var(--height);
padding: 5px 2px 5px 8px;
box-sizing: border-box;
position: absolute;
right: 0;
z-index: 3;
cursor: pointer;
svg {
fill: none;
stroke: var(--strong-color);
stroke-width: 2px;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dashoffset: 26;
stroke-dasharray: 26;
transition: stroke-dashoffset .6s ease;
}
}
.lock {
width: 180px;
height: var(--height);
position: absolute;
right: 0;
&::before,
&::after {
content: "";
position: absolute;
background: var(--svg-color);
pointer-events: none;
}
&::before {
right: 8px;
bottom: 9px;
width: 6px;
height: 6px;
border-radius: 50%;
transition: bottom .2s ease-out .4s, right .4s ease-out;
}
&::after {
right: 10px;
bottom: 5px;
width: 2px;
height: 10px;
border-radius: 2px;
transition: bottom .4s ease-out .4s, border-radius .2s ease-out .4s, width .2s ease-out .4s, right .4s ease-out, height .4s ease .8s;
}
svg {
display: block;
height: 100%;
width: 100%;
fill: none;
stroke: var(--svg-color);
stroke-width: 2px;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dashoffset: 263;
stroke-dasharray: 0 263 71 263;
transition: all .6s ease-out;
}
}
&.active {
input {
width: var(--width);
padding: 0 var(--height) 0 5px;
cursor: text;
box-sizing: border-box;
}
.check {
display: flex;
&.submit {
svg {
stroke-dashoffset: 0;
stroke-dasharray: 26;
}
& ~ .lock {
&::before,
&::after {
opacity: 0;
right: 9px;
transition: right .2s ease-out, opacity .2s ease-out;
}
}
}
&.active {
& ~ .lock {
&::before {
animation: wink-animation .6s linear alternate;
background: var(--medium-color);
}
&::after {
animation: wink-animation .6s linear alternate;
background: var(--medium-color);
}
}
}
}
.lock {
&::before {
right: 3px;
bottom: 11px;
transition: bottom .1s ease-out .1s, right .4s ease-out .2s, background .2s ease-out, opacity .2s ease-out;
}
&::after {
right: 15px;
bottom: 11px;
width: 6px;
height: 6px;
border-radius: 50%;
transition: height .2s ease-out, bottom .2s ease-out, border-radius .2s ease-out .2s, width .2s ease-out .2s, right .4s ease-out .2s, background .2s ease-out, opacity .2s ease-out;
}
svg {
stroke-dashoffset: 207;
stroke-dasharray: 0 263 177 263;
}
}
.indicator {
width: 180px;
height: var(--height);
position: absolute;
right: 0;
&::before {
content: "";
position: absolute;
left: 0;
bottom: 0;
width: 0;
height: 2px;
border-radius: 5px;
background: transparent;
z-index: 3;
transition: background .6s ease-out, width .6s ease-out;
}
&.weak {
&::before {
width: 33.3%;
background: var(--weak-color);
}
}
&.medium {
&::before {
width: 66.6%;
background: var(--medium-color);
}
}
&.strong {
&::before {
width: 100%;
background: var(--strong-color);
}
}
}
}
}
@keyframes wink-animation {
0% {
height: 6px;
}
10% {
height: 1px;
}
20% {
height: 6px;
}
80% {
height: 6px;
}
90% {
height: 1px;
}
100% {
height: 6px;
}
}
//--- ## BASIC #############
body {
background: #E8EBF3;
height: 100vh;
font: 400 16px 'Poppins', sans-serif;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.socials {
position: fixed;
display: block;
left: 20px;
bottom: 20px;
> a {
display: block;
width: 30px;
opacity: var(--opacity, .2);
transform: scale(var(--scale, .8));
transition: transform .3s cubic-bezier(0.38,-0.12, 0.24, 1.91);
&:hover {
--scale: 1;
}
}
}
}
View Compiled
var $ = (s, o = document) => o.querySelector(s);
var $$ = (s, o = document) => o.querySelectorAll(s);
$(".password").addEventListener("input", indicatorCheck);
$(".check").addEventListener("click", hideCheck);
$(".password").addEventListener("keyup", submit);
window.addEventListener("click", function(e){
if ($(".password").contains(e.target)){
$(".password").classList.add("active");
} else{
$(".password").classList.remove("active");
$(".password-input").value = "";
$(".indicator").classList.remove("weak", "medium", "strong");
$(".check").classList.remove("submit");
}
});
function indicatorCheck(){
var val = $(".password-input").value;
var strength = null;
if(val.length > 0) strength = "weak";
if(val.length > 3) strength = "medium";
if(val.length > 6) strength = "strong";
$(".indicator").classList.remove("weak", "medium", "strong");
$(".indicator").classList.add(strength);
$(".check").classList.remove("submit");
};
function hideCheck(){
$(".check").classList.toggle('active');
($(".password-input").type == 'password') ? $(".password-input").type = 'text' : $(".password-input").type = 'password';
};
function submit(e){
if (e.keyCode == 13) {
$(".check").classList.add("submit");
return false;
}
};
This Pen doesn't use any external JavaScript resources.