Runtime validation

by VeryGoodFiddle

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  <title>VGS Collect Credit Card Example</title>

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
        integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

  <!--Replace with generated for your organization JS file.-->
  <script type="text/javascript" src="https://js.verygoodvault.com/vgs-collect/1/vgs-collect-examples.js"></script>

  <style>
    body {
      margin-top: 100px;
      background-color: #feffff;
    }

    form {
      margin-bottom: 30px;
    }

    label {
      width: 100%;
      color: #72777f;
      font-size: 14px;
      margin-bottom: 0;
    }

    .form-group {
      height: 60px;
      padding: 0 15px;
      margin-bottom: 40px;
    }

    .form-group:last-child {
      border-bottom: none;
    }

    .form-field {
      width: 100%;
      display: block;
      height: 30px;
      font-size: 1rem;
      line-height: 1.5;
      color: #495057;
      border-bottom: 1px solid #cfd4da;
    }

    .form-field iframe {
      height: 100%;
      vertical-align: middle;
      width: 100%;
    }

    p {
      font-size: 14px;
      color: #464547;
      width: 85%;
      margin: 0 auto 15px;
    }

    pre {
      width: 85%;
      font-size: 10px;
      margin: 0 auto 15px;
    }

    .save-btn {
      width: 90%;
      margin: 0 auto 30px;
      border: none;
      background-color: #75c076;
    }

    .flex {
      width: 100%;
      display: flex;
    }

    .focus-valid {
      border-bottom: 1px solid #70b36c;
    }

    .focus-invalid {
      border-bottom: 1px solid red;
    }

    .error-message {
      font-size: 12px;
      color: red;
    }

  </style>
</head>
<body>
<main>
  <div>
    <form id="cc-form">
      <div...