JSFiddle - React, Tailwind, and code Playground
HTML
<div class='input-box'>
<input type='text'/>
<div class='tooltip'>
<div class='content'>
<div class='row'>
<span class='check'>
+
</span>
<span>
1 Capital Letter
</span>
</div>
<div class='row'>
<span class='check'>
+
</span>
<span>
1 Small Letter
</span>
</div>
<div class='row'>
<span class='check'>
+
</span>
<span>
8 Characters
</span>
</div>
</div>
</div>
</div>
CSS
body {
font-family: arial;
font-size: 14px;
color: #363636;
}
.content {
width: 90%;
margin: 0 auto;
height: 100%;
}
.input-box {
position: relative;
display: inline-block;
}
.tooltip {
position: absolute;
top: 100%;
left: 0px;
padding: 10px 0;
background-color: white;
opacity: 0;
transition: opacity 0.2s ease;
min-width: 100%;
}
input {
outline: none;
padding: 6px 7px;
border: 1px solid #ddd;
transition: border-color 0.2s ease;
margin: 0;
}
input:focus {
border: 1px solid teal;
transition: border-color 0.2s ease;
}
input:focus ~.tooltip {
opacity: 1;
transition: opacity 0.2s ease;
}
.row {
padding: 2px 0;
}
.check {
color: brown;
display: inline-block;
transform: rotate(45deg) scale(1.4);
-webkit-transform: rotate(45deg) scale(1.4);
}
.check.green {
color: green;
transition: color 0.3s ease;
-webkit-transition: color 0.3s ease;
transform: rotate(0);
-webkit-transform: rotate(0);
}
JavaScript
$(function() {
$('input').on('input', function() {
var length = $(this).val().length;
var tooltip = $(this).parent().children('.tooltip').first().children('.content').first();
var check = '';
if(length === 1) {
check = $(tooltip).children().first().children().first();
} else if(length === 2) {
check = $(tooltip).children().eq(1).children().first();
} else if(length === 3) {
check = $(tooltip).children().eq(2).children().first();
}
$(check).text('✔');
$(check).addClass('green');
});
});