Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="row">
  <div class="first-title">1 Personal Information</div>
  <div class="col col-span-7">
    <form>
      <div class="container">

        <div class="box--half">
          <label>First Name</label>
          <input type="text" id="f_name" name="firstName" placeholder="Elon" maxlength="20" required>
          <span class="error" aria-live="polite"></span>
        </div>
        <div class="box--half">
          <label>Last Name</label>
          <input type="text" id="l_name" name="l_name" placeholder="Musk" required> <span class="error" aria-live="polite"></span>
        </div>
        <div class="box--full">
          <label>Email</label>
          <input id="email" name="email" type="email" placeholder="elon@spacex.com" required>
          <span class="error" aria-live="polite"></span>
        </div>
        <div class="box--half">
          <label>Country</label>
          <select name="country" id="country" required>
<option value="Default">(Please choose a country)</option> 
<option value="US">United States</option>
</select>
          <span class="error" aria-live="polite"></span>
        </div>
        <div class="box--half">
          <label>Postal Code</label>
          <input type="text" id="p_code" name="p_code" placeholder="10001" maxlength="5" required>
          <span class="error" aria-live="polite"></span>
        </div>
        <div class="box--full">
          <label>Phone Number</label>
          <input type="tel" id="tel" name="tel" placeholder="(292) 692-93-92" id="tel" maxlength="15" required>
          <span class="error" aria-live="polite"></span>
        </div>
      </div>
      <div class="second-title">2 Payment Details</div>
      <div class="container">
        <div class="box--full">
          <label>Credit Card Number</label>
          <input type="text" id="cc_number" name="cc_number" placeholder="0000-0000-0000-0000" maxlength="19" required>
          <span class="error" aria-live="polite"></span>
        </div>
        <div class="box--half">
          <label>Security Code</label>
          <input type="text" id="sec_code" name="sec_code" placeholder="***" maxlength="3" required>
          <span class="error" aria-live="polite"></span>
        </div>
        <div class="box--half">
          <label>Expiration Date</label>
          <input type="text" id="exp_date" name="exp_date" placeholder="MM/YY" required>
          <span class="error" aria-live="polite"></span>
        </div>
        <input type="button" id="submit" value="Complete Purchase" onclick="validate()">
      </div>
    </form>
  </div>
  <div class="col col-span-2">
    <div class="container cart">
      <div class="box--full">
        <table>
          <tr>
            <th colspan="2">YOUR ORDER</th>
          </tr>
          <tr>
            <td>Apple Watch Sport</td>
            <td class="right">$ 580</td>
          </tr>
          <tr>
            <td>Modern Buckle</td>
            <td class="right">$ 380</td>
          </tr>
          <tr>
            <th colspan="2" class="table-border"></th>
          </tr>
          <tr>
            <td>Total Purchases</td>
            <td class="right">$ 960</td>
          </tr>
          <tr>
            <td>Estimated Tax</td>
            <td class="right">$ 0</td>
          </tr>
          <tr>
            <th colspan="2" class="table-border"></th>
          </tr>
          <tr>
            <td>Total</td>
            <td class="total">$ 960</td>
          </tr>
        </table>
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                ///// Some useful mixins
@mixin button-form {
  padding: 1.5rem;
  margin: .5rem;
  border: 0 none;
  font-size: 1.5em;
  border-bottom: 3px solid #5bb500;
  background-color: #6bd400;
  font-weight: $font-weight;
  color: #fff;
  &:hover,
  &:focus {
    cursor: pointer;
  }
}

//box model = border-box
@mixin box-sizing($box-model) {
  -webkit-box-sizing: $box-model; // Safari <= 5
  -moz-box-sizing: $box-model; // Firefox <= 19
  box-sizing: $box-model;
}

@mixin titles {
  font-family: "Roboto", "Helvetica", "Arial", sans-serif;
  font-size: 1em;
  font-weight: $font-weight;
  line-height: 1;
  letter-spacing: .02em;
  text-transform: uppercase;
}

///// Variables
$font-weight: bold;
$text-color: #2f383d;
$dotted: 2px dotted #D1D1D1;
$radius: 4px;
// form styles
* {
  @include box-sizing(border-box);
}

// Flexbox Styles
//Outer container
.row {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  width: 80%;
  margin: 0 auto;
  background-color: #f1f1f1;
}

.col {
  flex: 1 1 8%;
  margin: 0 0 0.5rem 0;
  padding: 0.5em 10px;
  box-sizing: border-box;
}

.col-span-7 {
  flex-basis: 58.3333%;
}

.col-span-2 {
  flex-basis: 16.6666%;
}

// Inner Container
.container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-flow: row wrap;
}

[class*="box--"] {
  display: flex;
  margin: .5rem;
  background: white;
  border-bottom: 3px solid #dedfdf;
}

.box--full {
  flex: 1 1 100%;
  flex-flow: column;
  padding: 1rem;
  border-radius: $radius;
}

.box--half {
  flex: 1 1 30%;
  flex-flow: column;
  padding: 1rem;
  border-radius: $radius;
  flex-shrink: 1;
  flex-basis: 250px; //effectively it's min width
}

@media all and (max-width: 568px) {
  .col-span-2 {
    flex-basis: 50%;
  }
  .col-span-6,
  .col-span-7,
  {
    flex-basis: 100%;
  }
}

// get rid of "default" iOS button styling for submit buttons
input[type=submit] {
  appearance: none;
}

// Most form inputs
input[type="email"],
input[type="password"],
input[type="text"],
input[type="search"],
input[type="tel"],
input[type="number"],
input[type="url"],
textarea {
  font-size: 1.3em;
  width: 100%;
}

label {
  font-weight: $font-weight;
  color: #000;
  font-size: 1em;
}

// Selects (dropdowns)
select {
  font-size: 1.3em;
  height: 2.1rem;
  line-height: 1.5em;
  width: 100%;
  margin-top: .25rem;
  background: transparent;
  &:hover {
    cursor: pointer;
  }
}

input,
select {
  border: none;
  padding-top: .5rem;
  padding-bottom: .5rem;
}

textarea:focus,
input:focus {
  outline: none;
}

.first-title {
  @include titles;
  width: 100%;
  padding-left: 10px;
  margin: 24px 0 16px;
}

.second-title {
  @include titles;
  width: 100%;
  margin: 30px 0 20px;
}

#submit {
  @include button-form;
  width: 100%;
  border-radius: $radius;
}

.error {
  color: orangered;
}

.cart {
  outline: $dotted;
  outline-offset: -13px;
}

table {
  width: 100%;
}

td,
th {
  padding: 10px;
  white-space: nowrap;
  text-align: left;
}

th {
  font-weight: $font-weight;
}

.total {
  font-weight: $font-weight;
  font-size: 2em;
  text-align: right;
}

.right {
  text-align: right;
}

.table-border {
  border-bottom: $dotted;
}
              
            
!

JS

              
                var firstName = document.getElementById("f_name");
var lastName = document.getElementById("l_name");
var eMail = document.getElementById("email");
var select = document.getElementById("country");
var postalCode = document.getElementById("p_code");
var phoneNumber = document.getElementById("tel");
var ccNumber = document.getElementById("cc_number");
var securityCode = document.getElementById("sec_code");
var expirationDate = document.getElementById("exp_date");
var emailFormat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
var ccFormat = /^\(?([0-9]{4})\)?[-. ]?([0-9]{4})[-. ]?([0-9]{4})?[-. ]?([0-9]{4})$/;
var numbers = /^[0-9]+$/;
var error = true;

function validate() {
  //checking fields
  if (firstName.value.length == 0 || firstName.value.length > 20 || firstName.value.match(numbers)) {
    var parent = firstName.parentElement;
    parent.querySelector(".error").innerText = "Required";
    parent.querySelector(".error").style.display = "block";
    error = true;
  } else {
    error = false;
    var parent = firstName.parentElement;
    parent.querySelector(".error").style.display = "none";
  }
  if (lastName.value.length == 0 || lastName.value.length > 20 || lastName.value.match(numbers)) {
    var parent = lastName.parentElement;
    parent.querySelector(".error").innerText = "Required";
    parent.querySelector(".error").style.display = "block";
    error = true;
  } else {
    error = false;
    var parent = lastName.parentElement;
    parent.querySelector(".error").style.display = "none";
  }
  if (!eMail.value.match(emailFormat)) {
    var parent = eMail.parentElement;
    parent.querySelector(".error").innerText = "Required";
    parent.querySelector(".error").style.display = "block";
    error = true;
  } else {
    error = false;
    var parent = eMail.parentElement;
    parent.querySelector(".error").style.display = "none";
  }
  if (select.value == "Default") {
    var parent = select.parentElement;
    parent.querySelector(".error").innerText = "Required";
    parent.querySelector(".error").style.display = "block";
    error = true;
  } else {
    error = false;
    var parent = select.parentElement;
    parent.querySelector(".error").style.display = "none";
  }
  if (!postalCode.value.match(numbers) || postalCode.value.length > 5) {
    var parent = postalCode.parentElement;
    parent.querySelector(".error").innerText = "Required";
    parent.querySelector(".error").style.display = "block";
    error = true;
  } else {
    error = false;
    var parent = postalCode.parentElement;
    parent.querySelector(".error").style.display = "none";
  }
  if (!phoneNumber.value.match(/^\d{10}$/)) {
    var parent = phoneNumber.parentElement;
    parent.querySelector(".error").innerText = "Required";
    parent.querySelector(".error").style.display = "block";
    error = true;
  } else {
    error = false;
    var parent = phoneNumber.parentElement;
    parent.querySelector(".error").style.display = "none";
  }
  if (!ccNumber.value.match(ccFormat)) {
    var parent = ccNumber.parentElement;
    parent.querySelector(".error").innerText = "Required";
    parent.querySelector(".error").style.display = "block";
    error = true;
  } else {
    error = false;
    var parent = ccNumber.parentElement;
    parent.querySelector(".error").style.display = "none";
  }
  if (!securityCode.value.match(numbers) || securityCode.value.length == 0 || securityCode.value.length > 3) {
    var parent = securityCode.parentElement;
    parent.querySelector(".error").innerText = "Required";
    parent.querySelector(".error").style.display = "block";
    error = true;
  } else {
    error = false;
    var parent = securityCode.parentElement;
    parent.querySelector(".error").style.display = "none";
  }
  if (expirationDate.value.length == 0 || expirationDate.value.length > 5) {
    var parent = expirationDate.parentElement;
    parent.querySelector(".error").innerText = "Required";
    parent.querySelector(".error").style.display = "block";
    error = true;
  } else {
    error = false;
    var parent = expirationDate.parentElement;
    parent.querySelector(".error").style.display = "none";
  }
  console.log(error);
  if (error == false) {
    window.location.assign('https://www.google.com');
  }

}
              
            
!
999px

Console