<!-- special thanks: https://www.freepik.es/ -->
<div class="overlay"></div>
<div class="container">
<div class="loginBox">
<div class="userImage">
<img src="http://bindy.es/Codepen-resources/img/catFace.png">
</div>
<form id="loginForm">
<div class="input-wrapper">
<label>Introduce tu email:</label>
<input type="email" name="" placeholder="E-mail">
<div class="error-email"><div class="email-msg"></div><div class="triangle"></div></div>
</div>
<div class="input-wrapper">
<label>Introduce tu contraseña:</label>
<input type="password" name="" placeholder="Password">
<div class="error-pass"><div class="pass-msg"></div><div class="triangle"></div></div>
</div>
<input type="button" name="" value="LOGIN" onclick="validateForm()">
</form>
</div>
</div>
<div class="confirmation showOk">
<img src="https://image.freepik.com/vector-gratis/lindo-personaje-de-gato_11823-526.jpg">
</div>
body, html {
height: 100%;
margin: 0;
font-family: "Arial";
font-weight: lighter;
color: #626262;
background-color: #66e8dc;
}
.container {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.loginBox {
width: 330px;
background-color: white;
box-shadow: 0px 0px 43px -2px rgba(135,130,135,1);
border-radius: 8px;
padding: 15px;
}
.userImage {
border-radius: 50%;
overflow: hidden;
width: 120px;
height: 120px;
margin: 10px auto 30px;
}
img {
width: 100%;
}
.input-wrapper {
position: relative;
}
.error-email, .error-pass {
position: absolute;
top: 5px;
padding: 5px 10px;
right: 0;
color: white;
background-color: #66e8dc;
border-radius: 10px;
}
.triangle {
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 10px solid #66e8dc;
position: absolute;
right: 18px;
bottom: -8px;
}
input {
display: block;
width: 300px;
padding: 15px 10px;
border-radius: 8px;
border: 1px solid #ececec;
margin: 10px 0;
}
input[type="button"] {
width: 100%;
margin-top: 35px;
background-color: #32bfb2;
color: white;
font-weight: lighter;
}
.warning {
border-color: red
}
.confirmation {
width: 200px;
position: absolute;
top: 0;
border-radius: 50%;
overflow: hidden;
height: 200px;
left: 50%;
margin-left: -100px;
top: 50%;
margin-top: -100px;
box-shadow: 10px 10px 10px;
z-index: 10
}
.overlay {
background: rgba(14, 14, 14, 0.57);
height: 100%;
position: absolute;
top: 0;
left: 0;
right: 0;
z-index: 9;}
.showOk {
animation: showOk 1s ease 1 normal;
width: 200px;
height: 200px;
}
@keyframes showOk {
from {
transform: scale(0);
opacity: 0
}
to {
transform: scale(1);
opacity: 1;
}
}
$(function(){
$(".error-pass, .error-email").hide();
$(".overlay").hide();
$(".confirmation").hide();
})
function checkEmail(email) {
var emailReg = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
return emailReg.test(email);
}
function validateForm() {
var countErrors = 0;
var emailInput = $("input[type=email]");
var passInput = $("input[type=password]");
if(!checkEmail($(emailInput).val())) {
$(".error-email").fadeIn();
$(".email-msg").html("Por favor, compruebe su email");
$(emailInput).addClass("warning");
countErrors++;
} else {
$(emailInput).removeClass("warning");
}
if(passInput.val().length < 5) {
$(".error-pass").fadeIn();
$(".pass-msg").html("La contraseña debe al menos 5 caracteres");
$(passInput).addClass("warning");
countErrors++;
} else {
$(passInput).removeClass("warning");
}
setTimeout(function showErrorMsg() {
$(".error-email, .error-pass").fadeOut();
}, 2000)
if(countErrors === 0) {
$(".overlay").show();
$(".confirmation").show();
}
}
This Pen doesn't use any external CSS resources.