<!-- TRY WRITING INVALID INPUT -->

<div class="form-wrap">
  <div class="input">
<label for="mail">Email address</label>
<input type="email" name="mail" autocomplete="off">
</div>
 <svg class="line">
</svg>
</div>
body {
  background: #002b36;
  font-family: 'Roboto Mono', monospace;
}

*:focus {
  outline: none;
}

.wrap {
  height: 100%;
  width: 100%;
  overflow: hidden;
  padding: 15px;
}

.form-wrap {
  position: relative;
  height: 50px;
  width: 400px;
  margin: 100px auto 0;
}

input {
  color: #fff;
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  padding-top: 5px;
  border: none;
  font-size: 1em;
  font-weight: 200;
  background: none;
  opacity: 0;
  font-family: 'Roboto Mono', monospace;
  transition: all 0.5s ease;
}

.active input {
  opacity: 1;
  transition: all 0.5s ease 0.5s;
}

svg {
  position: absolute;
  left: 0;
  top: 100%;
  overflow: visible;
  fill: none;
  z-index: 5;
  stroke: #fff;
  stroke-width: 3px;
}

label {
  color: #fff;
  position: absolute;
  top: 15px;
  font-size: 1.3em;
  transition: all 0.5s ease;
}

.active label {
  top: 0px;
  font-size: 1em;
  color: #FF5252;
  transition: all 0.5s ease 0.6s;
}

.active + svg {
  stroke: #FF5252;
  transition: stroke 0.4s ease 0.6s;
}

.input {
  height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.input:before {
  content: "";
  position: absolute;
  height: 26px;
  width: 3px;
  right: 15px;
  bottom: -50px;
  background-color: transparent;
  transform-origin: inherit;
  transform: rotate(0deg);
  transition: transform 0.4s ease, bottom 0.4s ease 0.3s, background-color 0.2s ease 0.6s;
}

.input:after {
  content: "";
  position: absolute;
  height: 26px;
  width: 3px;
  right: 15px;
  bottom: -50px;
  visibility: hidden;
  background-color: transparent;
  transform-origin: inherit;
  transform: rotate(0deg);
  transition: transform 0.4s ease, visibility 0.4s ease, bottom 0.4s ease 0.3s, background-color 0.2s ease 0.6s, height 0.2s ease 0.6s;
}

.valid:before {
  bottom: 10px;
  right: 16px;
  visibility: visible;
  background-color: #4CAF50;
  transform-origin: inherit;
  transform: rotate(40deg);
  transition: bottom 0.4s ease, transform 0.4s ease 0.3s;
}

.valid:after {
  bottom: 10px;
  height: 15px;
  visibility: visible;
  background-color: #4CAF50;
  transform-origin: inherit;
  transform: rotate(-45deg);
  transition: bottom 0.4s ease, visibility 0.4s ease 0.3s, transform 0.4s ease 0.3s;
}

.invalid:before {
  bottom: 10px;
  visibility: visible;
  background-color: #ff5252;
  transform: rotate(40deg);
  transition: bottom 0.4s ease, transform 0.4s ease 0.3s;
}

.invalid:after {
  height: 26px;
  bottom: 10px;
  visibility: visible;
  background-color: #ff5252;
  transform: rotate(-45deg);
  transition: bottom 0.4s ease, visibility 0.4s ease 0.3s, transform 0.4s ease 0.3s;
}
'use strict';
var textInput = document.querySelector('input');
var inputWrap = textInput.parentElement ;
var inputWidth = parseInt(getComputedStyle(inputWrap).width);
var svgText = Snap('.line');
var qCurve = inputWidth / 2;  // For correct curving on diff screen sizes
var textPath = svgText.path("M0 0 " + inputWidth + " 0");
var textDown = function(){
    textPath.animate({d:"M0 0 Q" + qCurve + " 40 " + inputWidth + " 0"},150,mina.easeout);
};
var textUp = function(){
  textPath.animate({d:"M0 0 Q" + qCurve + " -30 " + inputWidth + " 0"},150,mina.easeout);
};
var textSame = function(){
  textPath.animate({d:"M0 0 " + inputWidth + " 0"},200,mina.easein);
};
var textRun = function(){
  setTimeout(textDown, 200 );
  setTimeout(textUp, 400 );
  setTimeout(textSame, 600 );
};

(function(){
    textInput.addEventListener('focus', function(){
      var parentDiv = this.parentElement;
      parentDiv.classList.add('active');
      textRun();
      this.addEventListener('blur', function(){
        var rg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.]{3,9})+\.([A-Za-z]{2,4})$/;
        this.value == 0 ? parentDiv.classList.remove('active') : null;
        !rg.test(this.value) && this.value != 0 ?
         (parentDiv.classList.remove('valid'), parentDiv.classList.add('invalid'), parentDiv.style.transformOrigin="center")
         : rg.test(this.value) && this.value != 0 ?
        (parentDiv.classList.add('valid'), parentDiv.classList.remove('invalid'), parentDiv.style.transformOrigin="bottom") :null;
        });
     parentDiv.classList.remove('valid', 'invalid')
    });
})();

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/snap.svg/0.4.1/snap.svg-min.js