LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

Welcome back to the internet!

You've successfully managed to log into a nonexistant account in order to test a login dialog box.
If you like it, you are welcomed to use it wherever you want, no strings attached.

Rerun the whole thing.

Welcome to the internet!

You've successfully managed to register for a nonexistant account in order to test a registration dialog box.
If you like it, you are welcomed to use it wherever you want, no strings attached.

Rerun the whole thing.

Log in

Have you forgotten your
username or password?

Do you wish to register
for ?

Register

Return to ?

CSS
@import url(https://fonts.googleapis.com/css?family=Roboto:400,500,700,300,100);
.pad-top-20 {
  padding-top: 20px;
}
.pad-btm-20 {
  padding-bottom: 20px;
}
.pad-sep-20 {
  padding-top: 20px;
  padding-bottom: 20px;
}
.pad-top-40 {
  padding-top: 40px;
}
.pad-btm-40 {
  padding-bottom: 40px;
}
.pad-sep-40 {
  padding-top: 40px;
  padding-bottom: 40px;
}
.pad-top-60 {
  padding-top: 60px;
}
.pad-btm-60 {
  padding-bottom: 60px;
}
.pad-sep-60 {
  padding-top: 60px;
  padding-bottom: 60px;
}
.pad-top-80 {
  padding-top: 80px;
}
.pad-btm-80 {
  padding-bottom: 80px;
}
.pad-sep-80 {
  padding-top: 80px;
  padding-bottom: 80px;
}
.pad-top-100 {
  padding-top: 100px;
}
.pad-btm-100 {
  padding-bottom: 100px;
}
.pad-sep-100 {
  padding-top: 100px;
  padding-bottom: 100px;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  padding: 0;
  color: #fff;
  overflow: hidden;
  background-color: #222;
  font-size: 14px;
  position: relative;
  font-family: 'Roboto', Helvetica, Arial, sans-serif;
}
h1,
.h1,
h2,
.h2,
h3,
.h3 {
  font-weight: 300;
  color: #22A7F0;
}
.fix-middle {
  position: absolute;
  padding: 10px;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  -moz-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  z-index: 3;
}
.dialog {
  color: #222;
  -webkit-perspective: 1200px;
  -moz-perspective: 1200px;
  -ms-perspective: 1200px;
  -o-perspective: 1200px;
  perspective: 1200px;
  z-index: 1000;
  opacity: 1;
  visibility: visible;
  -webkit-transition: opacity 0.2s cubic-bezier(0.25, 0.5, 0.5, 0.9), visibility 0.2s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  -moz-transition: opacity 0.2s cubic-bezier(0.25, 0.5, 0.5, 0.9), visibility 0.2s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  -ms-transition: opacity 0.2s cubic-bezier(0.25, 0.5, 0.5, 0.9), visibility 0.2s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  transition: opacity 0.2s cubic-bezier(0.25, 0.5, 0.5, 0.9), visibility 0.2s cubic-bezier(0.25, 0.5, 0.5, 0.9);
}
.dialog,
.dialog .dialog-front,
.dialog .dialog-back {
  width: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  padding: 0;
  margin: 0;
  -webkit-transform: translate(-50%, -50%);
  -moz-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}
.dialog.dialog-effect-in {
  -webkit-animation: showDialog 1000ms linear both;
  -moz-animation: showDialog 1000ms linear both;
  -ms-animation: showDialog 1000ms linear both;
  animation: showDialog 1000ms linear both;
}
.dialog.shakeit {
  -webkit-animation: shakeDialog 300ms linear both;
  -moz-animation: shakeDialog 300ms linear both;
  -ms-animation: shakeDialog 300ms linear both;
  animation: shakeDialog 300ms linear both;
}
.dialog .dialog-content {
  width: 300px;
  background: #fff;
  /* Old browsers */
  background: -moz-radial-gradient(center, ellipse cover, #ffffff 59%, #e5e5e5 100%);
  /* FF3.6+ */
  background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(59%, #ffffff), color-stop(100%, #e5e5e5));
  /* Chrome,Safari4+ */
  background: -webkit-radial-gradient(center, ellipse cover, #ffffff 59%, #e5e5e5 100%);
  /* Chrome10+,Safari5.1+ */
  background: -o-radial-gradient(center, ellipse cover, #ffffff 59%, #e5e5e5 100%);
  /* Opera 12+ */
  background: -ms-radial-gradient(center, ellipse cover, #ffffff 59%, #e5e5e5 100%);
  /* IE10+ */
  background: radial-gradient(ellipse at center, #ffffff 59%, #e5e5e5 100%);
  /* W3C */
  border-radius: 6px;
  -webkit-box-shadow: 0 2px 12px -3px rgba(0, 0, 0, 0.6);
  -moz-box-shadow: 0 2px 12px -3px rgba(0, 0, 0, 0.6);
  -ms-box-shadow: 0 2px 12px -3px rgba(0, 0, 0, 0.6);
  box-shadow: 0 2px 12px -3px rgba(0, 0, 0, 0.6);
  padding: 20px 25px;
}
.dialog .dialog-front,
.dialog .dialog-back {
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  -ms-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-transition: all 0.4s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  -moz-transition: all 0.4s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  -ms-transition: all 0.4s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  transition: all 0.4s cubic-bezier(0.25, 0.5, 0.5, 0.9);
}
.dialog .dialog-front {
  -webkit-transform: translate(-50%, -50%) rotateX(0deg) rotateY(0deg);
  -moz-transform: translate(-50%, -50%) rotateX(0deg) rotateY(0deg);
  -ms-transform: translate(-50%, -50%) rotateX(0deg) rotateY(0deg);
  -o-transform: translate(-50%, -50%) rotateX(0deg) rotateY(0deg);
  z-index: 900;
}
.dialog .dialog-back {
  -webkit-transform: translate(-50%, -50%) rotateY(-180deg);
  -moz-transform: translate(-50%, -50%) rotateY(-180deg);
  -ms-transform: translate(-50%, -50%) rotateY(-180deg);
  -o-transform: translate(-50%, -50%) rotateY(-180deg);
  z-index: 800;
}
.dialog.flip .dialog-front {
  z-index: 800;
  visibility: hidden;
  -webkit-transform: translate(-50%, -50%) rotateY(180deg);
  -moz-transform: translate(-50%, -50%) rotateY(180deg);
  -ms-transform: translate(-50%, -50%) rotateY(180deg);
  -o-transform: translate(-50%, -50%) rotateY(180deg);
}
.dialog.flip .dialog-back {
  z-index: 900;
  visibility: visible;
  -webkit-transform: translate(-50%, -50%) rotateX(0deg) rotateY(0deg);
  -moz-transform: translate(-50%, -50%) rotateX(0deg) rotateY(0deg);
  -ms-transform: translate(-50%, -50%) rotateX(0deg) rotateY(0deg);
  -o-transform: translate(-50%, -50%) rotateX(0deg) rotateY(0deg);
}
.dialog.dialog-effect-out {
  z-index: 1;
  opacity: 0;
  visibility: hidden;
}
.dialog.dialog-effect-out .dialog-front {
  -webkit-transform: translate(-50%, -20%) rotateX(-30deg);
  -moz-transform: translate(-50%, -20%) rotateX(-30deg);
  -ms-transform: translate(-50%, -20%) rotateX(-30deg);
  -o-transform: translate(-50%, -20%) rotateX(-30deg);
}
.dialog.dialog-effect-out .dialog-back {
  -webkit-transform: translate(-50%, -20%) rotateX(-30deg) rotateY(-180deg);
  -moz-transform: translate(-50%, -20%) rotateX(-30deg) rotateY(-180deg);
  -ms-transform: translate(-50%, -20%) rotateX(-30deg) rotateY(-180deg);
  -o-transform: translate(-50%, -20%) rotateX(-30deg) rotateY(-180deg);
}
.dialog.dialog-effect-out.flip .dialog-front {
  -webkit-transform: translate(-50%, -20%) rotateX(-30deg) rotateY(180deg);
  -moz-transform: translate(-50%, -20%) rotateX(-30deg) rotateY(180deg);
  -ms-transform: translate(-50%, -20%) rotateX(-30deg) rotateY(180deg);
  -o-transform: translate(-50%, -20%) rotateX(-30deg) rotateY(180deg);
}
.dialog.dialog-effect-out.flip .dialog-back {
  -webkit-transform: translate(-50%, -20%) rotateX(-30deg) rotateY(0deg);
  -moz-transform: translate(-50%, -20%) rotateX(-30deg) rotateY(0deg);
  -ms-transform: translate(-50%, -20%) rotateX(-30deg) rotateY(0deg);
  -o-transform: translate(-50%, -20%) rotateX(-30deg) rotateY(0deg);
}
.dialog.dialog-effect-out .dialog-content {
  background: #00B16A;
}
.dialog.dialog-effect-out .dialog-content .dialog-form {
  visibility: hidden;
}
.dialog .dialog-form {
  -webkit-animation: swooshUp30 300ms linear both;
  -moz-animation: swooshUp30 300ms linear both;
  -ms-animation: swooshUp30 300ms linear both;
  animation: swooshUp30 300ms linear both;
  -webkit-animation-delay: 300ms;
  -moz-animation-delay: 300ms;
  -ms-animation-delay: 300ms;
  animation-delay: 300ms;
}
.dialog .dialog-form legend {
  margin-bottom: 40px;
  font-size: 26px;
  font-weight: 300;
  color: #222;
  border-bottom: none;
}
.dialog .dialog-form .form-group {
  margin-bottom: 20px;
  position: relative;
}
.dialog .dialog-form .form-group .form-control {
  color: #222;
  background-color: transparent;
  border: none;
  border-bottom: 2px solid #222;
  border-radius: 0;
  -webkit-box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  box-shadow: none;
}
.dialog .dialog-form .form-group label {
  display: inline-block;
  max-width: 100%;
  margin-bottom: 5px;
  font-weight: 700;
}
.dialog .dialog-form .form-group.has-error .error-msg {
  display: block;
}
.dialog .dialog-form .form-group.has-error label {
  color: #E74C3C;
}
.dialog .dialog-form .form-group.has-error .form-control {
  border-color: #E74C3C;
}
.dialog .dialog-form .form-group .checkbox label {
  padding-left: 40px;
}
.dialog .dialog-form .form-group .checkbox input[type="checkbox"] {
  width: 20px;
  height: 20px;
  background: none;
  border: 2px solid #222;
  margin-left: -40px;
  -webkit-appearance: none;
  appearance: none;
}
.dialog .dialog-form .form-group .checkbox input[type="checkbox"]:hover {
  background-color: #e6e6e6;
}
.dialog .dialog-form .form-group .checkbox input[type="checkbox"]:checked {
  background-color: #222;
}
.dialog .dialog-form .form-group .checkbox input[type="checkbox"]:disabled {
  background-color: #6f6f6f;
  border-color: #555555;
}
.dialog .dialog-form .error-msg {
  position: absolute;
  top: 50%;
  left: 0;
  right: auto;
  background-color: #E74C3C;
  color: #fff;
  padding: 10px;
  z-index: 3;
  max-width: 150px;
  border-radius: 3px;
  -webkit-transform: translate(-110%, -50%);
  -moz-transform: translate(-110%, -50%);
  -ms-transform: translate(-110%, -50%);
  transform: translate(-110%, -50%);
  -webkit-animation: swooshleft 200ms ease-in-out both;
  -moz-animation: swooshleft 200ms ease-in-out both;
  -ms-animation: swooshleft 200ms ease-in-out both;
  animation: swooshleft 200ms ease-in-out both;
  display: none;
}
.dialog .dialog-form .error-msg:after {
  position: absolute;
  content: '';
  top: 50%;
  right: 0;
  -webkit-transform: translate(97%, -50%);
  -moz-transform: translate(97%, -50%);
  -ms-transform: translate(97%, -50%);
  transform: translate(97%, -50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 10px 0 10px 10px;
  border-color: transparent transparent transparent #E74C3C;
}
.dialog .dialog-form .btn {
  font-weight: 700;
  border-width: 0;
  border-radius: 0;
  text-transform: uppercase;
  -webkit-transition: all 0.2s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  -moz-transition: all 0.2s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  -ms-transition: all 0.2s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  transition: all 0.2s cubic-bezier(0.25, 0.5, 0.5, 0.9);
}
.dialog .dialog-form .btn.btn-default {
  color: #fff;
  background-color: #446CB3;
  margin: 0 -10%;
  width: 120%;
  outline: none;
}
.dialog .dialog-form .btn.btn-default:hover {
  background-color: #222;
  color: #fff;
}
.dialog .dialog-form .btn.btn-default:active,
.dialog .dialog-form .btn.btn-default:focus {
  background-color: #222;
  color: #fff;
}
@-webkit-keyframes swooshUp30 {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
@-moz-keyframes swooshUp30 {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
@keyframes swooshUp30 {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
@-webkit-keyframes swooshleft {
  0% {
    -webkit-transform: translate(-90%, -50%);
    -moz-transform: translate(-90%, -50%);
    -ms-transform: translate(-90%, -50%);
    transform: translate(-90%, -50%);
  }
  100% {
    -webkit-transform: translate(-110%, -50%);
    -moz-transform: translate(-110%, -50%);
    -ms-transform: translate(-110%, -50%);
    transform: translate(-110%, -50%);
  }
}
@-moz-keyframes swooshleft {
  0% {
    -webkit-transform: translate(-90%, -50%);
    -moz-transform: translate(-90%, -50%);
    -ms-transform: translate(-90%, -50%);
    transform: translate(-90%, -50%);
  }
  100% {
    -webkit-transform: translate(-110%, -50%);
    -moz-transform: translate(-110%, -50%);
    -ms-transform: translate(-110%, -50%);
    transform: translate(-110%, -50%);
  }
}
@keyframes swooshleft {
  0% {
    -webkit-transform: translate(-90%, -50%);
    -moz-transform: translate(-90%, -50%);
    -ms-transform: translate(-90%, -50%);
    transform: translate(-90%, -50%);
  }
  100% {
    -webkit-transform: translate(-110%, -50%);
    -moz-transform: translate(-110%, -50%);
    -ms-transform: translate(-110%, -50%);
    transform: translate(-110%, -50%);
  }
}
@-webkit-keyframes shakeDialog {
  0% {
    left: 51%;
  }
  25% {
    left: 49%;
  }
  50% {
    left: 51%;
  }
  100% {
    left: 50%;
  }
}
@-moz-keyframes shakeDialog {
  0% {
    left: 51%;
  }
  25% {
    left: 49%;
  }
  50% {
    left: 51%;
  }
  100% {
    left: 50%;
  }
}
@keyframes shakeDialog {
  0% {
    left: 51%;
  }
  25% {
    left: 49%;
  }
  50% {
    left: 51%;
  }
  100% {
    left: 50%;
  }
}
/* Generated with Bounce.js. Edit at https://goo.gl/KtDT8H */
@-webkit-keyframes showDialog {
  0% {
    -webkit-transform: matrix3d(0.8, 0, 0, 0, 0, 0.8, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(0.8, 0, 0, 0, 0, 0.8, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  7.61% {
    -webkit-transform: matrix3d(0.907, 0, 0, 0, 0, 0.907, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(0.907, 0, 0, 0, 0, 0.907, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  11.41% {
    -webkit-transform: matrix3d(0.948, 0, 0, 0, 0, 0.948, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(0.948, 0, 0, 0, 0, 0.948, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  15.12% {
    -webkit-transform: matrix3d(0.976, 0, 0, 0, 0, 0.976, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(0.976, 0, 0, 0, 0, 0.976, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  18.92% {
    -webkit-transform: matrix3d(0.996, 0, 0, 0, 0, 0.996, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(0.996, 0, 0, 0, 0, 0.996, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  22.72% {
    -webkit-transform: matrix3d(1.008, 0, 0, 0, 0, 1.008, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(1.008, 0, 0, 0, 0, 1.008, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  30.23% {
    -webkit-transform: matrix3d(1.014, 0, 0, 0, 0, 1.014, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(1.014, 0, 0, 0, 0, 1.014, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  50.25% {
    -webkit-transform: matrix3d(1.003, 0, 0, 0, 0, 1.003, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(1.003, 0, 0, 0, 0, 1.003, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  70.27% {
    -webkit-transform: matrix3d(0.999, 0, 0, 0, 0, 0.999, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(0.999, 0, 0, 0, 0, 0.999, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  100% {
    -webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
}
@keyframes showDialog {
  0% {
    -webkit-transform: matrix3d(0.8, 0, 0, 0, 0, 0.8, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(0.8, 0, 0, 0, 0, 0.8, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  7.61% {
    -webkit-transform: matrix3d(0.907, 0, 0, 0, 0, 0.907, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(0.907, 0, 0, 0, 0, 0.907, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  11.41% {
    -webkit-transform: matrix3d(0.948, 0, 0, 0, 0, 0.948, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(0.948, 0, 0, 0, 0, 0.948, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  15.12% {
    -webkit-transform: matrix3d(0.976, 0, 0, 0, 0, 0.976, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(0.976, 0, 0, 0, 0, 0.976, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  18.92% {
    -webkit-transform: matrix3d(0.996, 0, 0, 0, 0, 0.996, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(0.996, 0, 0, 0, 0, 0.996, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  22.72% {
    -webkit-transform: matrix3d(1.008, 0, 0, 0, 0, 1.008, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(1.008, 0, 0, 0, 0, 1.008, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  30.23% {
    -webkit-transform: matrix3d(1.014, 0, 0, 0, 0, 1.014, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(1.014, 0, 0, 0, 0, 1.014, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  50.25% {
    -webkit-transform: matrix3d(1.003, 0, 0, 0, 0, 1.003, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(1.003, 0, 0, 0, 0, 1.003, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  70.27% {
    -webkit-transform: matrix3d(0.999, 0, 0, 0, 0, 0.999, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(0.999, 0, 0, 0, 0, 0.999, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
  100% {
    -webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  }
}
#successful_login,
#successful_registration {
  opacity: 0;
  visibility: hidden;
  -webkit-transition: opacity 0.4s cubic-bezier(0.25, 0.5, 0.5, 0.9), visibility 0.6s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  -moz-transition: opacity 0.4s cubic-bezier(0.25, 0.5, 0.5, 0.9), visibility 0.6s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  -ms-transition: opacity 0.4s cubic-bezier(0.25, 0.5, 0.5, 0.9), visibility 0.6s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  transition: opacity 0.4s cubic-bezier(0.25, 0.5, 0.5, 0.9), visibility 0.6s cubic-bezier(0.25, 0.5, 0.5, 0.9);
}
#successful_login.active,
#successful_registration.active {
  opacity: 1;
  visibility: visible;
}
JS
    // The "getFormData()" function retrieves the names and values of each input field in the form; 

    function getFormData(form) {
      var data = {};
      $(form).find('input, select').each(function() {
        if (this.tagName.toLowerCase() == 'input') {
          if (this.type.toLowerCase() == 'checkbox') {
            data[this.name] = this.checked;
          } else if (this.type.toLowerCase() != 'submit') {
            data[this.name] = this.value;
          }
        } else {
          data[this.name] = this.value;
        }
      });
      return data;
    }

    // The "addFormError()" function, when called, adds the "error" class to the form-group that wraps around the "formRow" attribute;

    function addFormError(formRow, errorMsg) {
      var errorMSG = '' + errorMsg + '';
      $(formRow).parents('.form-group').addClass('has-error');
      $(formRow).parents('.form-group').append(errorMSG);
      $('#dialog').removeClass('dialog-effect-in');
      $('#dialog').addClass('shakeit');
      setTimeout(function() {
        $('#dialog').removeClass('shakeit');
      }, 300);
    }

    // FORM HANDLER:

    // form_name - This attribute ties the form-handler function to the form you want to submit through ajax. Requires an ID (ex: #myfamousid)
    // custom_validation - 

    function form_handler(form_name, custom_validation, success_message, error_message, success_function, error_function) {
      $(form_name).find('input[type="submit"]').on('click', function(e) { // if submit button is clicked

        window.onbeforeunload = null; // cancels the alert message for unsaved changes (if such function exists)

        $(form_name).find('.form-group .error-msg').remove();
        var submitButton = this;
        submitButton.disabled = true; // Disables the submit buttton until the rows pass validation or we get a response from the server.

        var form = $(form_name)[0];
        // The custom validation function must return true or false.
        if (custom_validation != null) {
          if (!custom_validation(form, getFormData(form))) {
            submitButton.disabled = false;
            return false;
          }
        }
        e.preventDefault(); //STOP default action
      });
      $(document).click(function(e) { // Whenever the user clicks inside the form, the error messages will be removed.
        if ($(e.target).closest(form_name).length) {
          $(form_name).find('.form-group').removeClass('has-error');
          setTimeout(function() {
            $(form_name).find('.form-group .error-msg').remove();
          }, 300);
        } else {
          return
        }
      });
    }

    // LOGIN FORM: Validation function
    function validate_login_form(form, data) {
      if (data.user_username == "") {
        // if username variable is empty
        addFormError(form["user_username"], 'The username is invalid');
        return false; // stop the script if validation is triggered
      }

      if (data.user_password == "") {
        // if password variable is empty
        addFormError(form["user_password"], 'The password is invalid');
        return false; // stop the script if validation is triggered
      }

      $('#dialog').removeClass('dialog-effect-in').removeClass('shakeit');
      $('#dialog').addClass('dialog-effect-out');

      $('#successful_login').addClass('active');
      //return true;
    }

    // REGISTRATION FORM: Validation function
    function validate_registration_form(form, data) {
      if (data.user_username == "") {
        // if username variable is empty
        addFormError(form["user_username"], 'The username is invalid');
        return false; // stop the script if validation is triggered
      }

      if (data.user_password == "") {
        // if password variable is empty
        addFormError(form["user_password"], 'The password is invalid');
        return false; // stop the script if validation is triggered
      }

      if (data.user_cnf_password == "" || data.user_password != data.user_cnf_password) {
        // if password variable is empty
        addFormError(form["user_cnf_password"], "The passwords don't match");
        return false; // stop the script if validation is triggered
      }

      if (!data.user_terms) {
        // if password variable is empty
        addFormError(form["user_terms"], "You need to read and accept the Terms and Conditions before proceeding");
        return false; // stop the script if validation is triggered
      }
      
      $('#dialog').removeClass('dialog-effect-in').removeClass('shakeit');
      $('#dialog').addClass('dialog-effect-out');
      
      $('#successful_registration').addClass('active');
      //return true;
    }

    form_handler("#login_form", validate_login_form, null, null, null, null, null, null);
    form_handler("#register_form", validate_registration_form, null, null, null, null, null, null);

    var dialogBox = $('#dialog');

    dialogBox.on('click', 'a.user-actions', function() {
      dialogBox.toggleClass('flip');
    });

    $('#successful_login,#successful_registration').on('click', 'a.dialog-reset', function() {
      $('#successful_login,#successful_registration').removeClass('active');
      dialogBox.removeClass('dialog-effect-out').addClass('dialog-effect-in');
      document.getElementById('login_form').reset();
      document.getElementById('register_form').reset();
    });
Host Instantly Drag and Drop Website Builder

 

Description

This is a simple login widget with CSS3 animations and a simple jQuery validation. Feel free to reuse the components or the whole thing.
Term
Mon, 11/27/2017 - 21:37

Related Codes

Pen ID
Pen ID
Pen ID