<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>CodePen - Registration form</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css'><link rel="stylesheet" href="./style.css">
</head>
<body>
<!-- partial:index.partial.html -->
<div class="container">
<h1>Create your account</h1>
<h2>
Get started in seconds by registering your free account</h2><i class="fa fa-icon"></i>
<div class="inputContainer">
<input class="username" type="text" placeholder="Username" required="required"/>
<div class="bar"></div>
<p>Username is taken</p><i class="fa fa-user"></i>
</div>
<div class="inputContainer">
<input class="password" type="email" placeholder="Email" required="required"/>
<div class="bar"></div>
<p>Invalid email address</p><i class="fa fa-envelope"></i>
</div>
<div class="inputContainer">
<input class="password" pattern=".{5,}" type="password" placeholder="Password" required="required"/>
<div class="bar"></div>
<p>Password must be at least 5 characters long</p><i class="fa fa-key"></i>
</div>
<button value="Register">Register</button>
</div>
<!-- partial -->
</body>
</html>
body {
background: #FEFEFE;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.container {
position: absolute;
width: 400px;
background: #ffffff;
border: 2px solid #E0E0E0;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
padding: 20px;
text-align: center;
}
.container h1 {
font-size: 2.3em;
margin-top: 30px;
}
.container h2 {
font-size: 1.4em;
margin-top: 30px;
}
.inputContainer {
position: relative;
width: 370px;
height: 1.7em;
background: #e0e0e0;
padding: 0px 0px 2px 0px;
margin: 60px auto;
}
.inputContainer input {
z-index: 10;
position: relative;
width: 290px;
height: 90%;
left: 0;
top: 0;
background-color: white;
padding: 0;
margin: 0;
border: none;
font-size: 1.3em;
padding: 0px 40px;
outline: none;
}
.inputContainer .bar {
top: 0;
position: absolute;
width: 0%;
height: 100%;
background: #e0e0e0;
left: 50%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
}
.inputContainer .bar + p {
margin-top: 20px;
color: #F94033;
opacity: 0;
-webkit-transition: opacity 400ms;
transition: opacity 400ms;
}
.inputContainer i {
position: absolute;
top: 40%;
left: 10px;
z-index: 20;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
font-size: 1.2em;
}
input:focus + .bar {
background: #2C9ECA;
-webkit-animation: 200ms bar-width forwards;
animation: 200ms bar-width forwards;
}
input:valid + .bar {
background: #80BA4E;
-webkit-animation: 200ms bar-width1 forwards;
animation: 200ms bar-width1 forwards;
}
input:not(:placeholder-shown):not(:valid) + .bar {
background: #F94033;
-webkit-animation: 200ms bar-width2 forwards;
animation: 200ms bar-width2 forwards;
}
input:not(:placeholder-shown):not(:valid) + .bar + p {
opacity: 1;
}
@-webkit-keyframes bar-width {
0% {
width: 0%;
}
100% {
width: 99.8%;
}
}
@keyframes bar-width {
0% {
width: 0%;
}
100% {
width: 99.8%;
}
}
@-webkit-keyframes bar-width1 {
0% {
width: 0%;
}
100% {
width: 99.8%;
}
}
@keyframes bar-width1 {
0% {
width: 0%;
}
100% {
width: 99.8%;
}
}
@-webkit-keyframes bar-width2 {
0% {
width: 0%;
}
100% {
width: 99.8%;
}
}
@keyframes bar-width2 {
0% {
width: 0%;
}
100% {
width: 99.8%;
}
}
button {
width: 380px;
height: 80px;
background-color: #2C9ECA;
border: none;
color: #FFFFFF;
font-size: 1.4em;
cursor: pointer;
margin-top: 15px;
}
field_username = document.getElementById('username');
field_username.oninvalid = function(event) {
event.target.setCustomValidity('Username should only contain lowercase letters. e.g. john');
}