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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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="main-container">
  <div class="title-section">
    <img id="logo" src="https://www.blissfullemon.com/wp-content/uploads/2018/09/code-fizz-light.png" alt="Code Fizz Logo" />
    <h2>Discover what all the fizz is about.</h2>
    <div class="subtext">[ membership is free ]</div>
  </div>
  <div class="form-section">
    <h1>Become A Member</h1>
    <form id="signup">
      <label for="fullName" id="fullNameLabel">Full Name</label>
        <div class="errorText" id="nameError">Name is required.</div>
        <div class="inputArea">
          <div class="status">
            <i id="nameCheck" class="far fa-check-circle"></i>
            <i id="nameX" class="far fa-times-circle" 
               onmouseover="displayNameErrorMsg()"
               onmouseout="hideNameErrorMsg()"></i>
          </div>
          <input id="fullName" type="text" onchange="checkName()" 
                 placeholder="Code Monkey Gregg" required />
        </div>
      <label for="email" id="emailLabel">Email</label>
        <div class="errorText" id="emailError">Email address is required.</div>
        <div class="inputArea">
          <div class="status">
            <i id="emailCheck" class="far fa-check-circle"></i>
            <i id="emailX" class="far fa-times-circle"
               onmouseover="displayEmailErrorMsg()"
               onmouseout="hideEmailErrorMsg()"></i>
          </div>
          <input id="email" type="email" onchange="checkEmail()" 
                 placeholder="codergregg@gmail.com" required />
        </div>
      <label for="password" id="passwordLabel">Password</label>
        <div class="errorText" id="passwordError">Password is required.</div>
        <div class="inputArea">
          <div class="status">
            <i id="passwordCheck" class="far fa-check-circle"></i>
            <i id="passwordX" class="far fa-times-circle"
               onmouseover="displayPasswordErrorMsg()"
               onmouseout="hidePasswordErrorMsg()"></i>
          </div>
          <input id="password" type="password" onchange="checkPassword()" 
                 placeholder="8-21 characters required" required />
        </div>
      <button id="signupButton" type="button" onClick="handleButton()">Sign Up</button>
    </form>
    <div class="signInText">Already a member? <a href="#">Sign In</a></div>
  </div>
</div>
              
            
!

CSS

              
                $decorativeFont: 'Corben', cursive;
$headerFont: 'Arima Madurai', cursive;
$mainFont: 'Source Sans Pro', sans-serif;
$codeFont: 'Source Code Pro', monospace;
$offwhite: #FCFAFA;
$gray: #333333;
$blue: #277AA7;
$orange: #ff731c;
$green: #89e166;
$red: #c9172f;

html {
  background-color: $offwhite;
  font-family: $mainFont;
  color: $gray;
}

.main-container {
  width: 80%;
  min-width: 300px;
  margin: 20px auto;
  background-color: white;
  box-shadow: 4px 4px 10px $gray;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  flex-wrap: wrap;
}

.title-section {
  background-color: $blue;
  color: white;
  text-align: center;
  padding: 3%;
  width: 200px;
  flex-grow: 1;
}

#logo {
  width: 80%;
  max-width: 200px;
  margin-top: 3%;
}

.form-section {
  padding: 3% 8%;
  flex-grow: 2;
}

h1 {
  text-align: center;
  font-family: $decorativeFont;
}

h2, h3, h4, h5, h6 {
  font-family: $headerFont;
  font-weight: 200;
}

h2 {
  line-height: 1.2em;
  margin-top: 30px;
}

.subtext {
  margin-top: 60px;
}

label {
  width: 30%;
  display: inline;
  font-family: $headerFont;
  font-weight: 600;
  font-size: 0.9em;
}

.inputArea {
  border-bottom: 2px solid $gray;
  margin-bottom: 10px;
}

input {
  width: 90%;
  display: inline;
  padding: 8px 0px;
  border: none;
  font-size: 18px;
  font-family: $mainFont;
}

input[type=text]:focus, 
input[type=text]:active, 
input[type=password]:focus, 
input[type=password]:active {
  outline: none;
  background: none;
}

button {
  display: block;
  text-align: center;
  margin: 30px auto;
  color: white;
  background-color: $orange;
  border: none;
  padding: 8px 20px 4px;
  text-transform: uppercase;
  font-family: $headerFont;
  font-size: 1.2em; 
}

button:hover {
  background-color: $gray;
}

.signInText {
  text-align: center;
  margin: 30px auto;
}

a {
  color: $gray;
  text-decoration: none;
  border-bottom: 2px solid $green;
}

a:hover {
  border-bottom: 2px solid $blue;
}

.errorText {
  position: relative;
  width: 200px;
  font-size: 0.9em;
  padding-top: 4px;
  color: $red;
  float: right;
  text-align: right;
  visibility: hidden;
}

.status {
  position: relative;
  float: right;
  top: 12px;
  width: 1.2em;
  height: 1.2em;
  text-align: center;
}

.far {
  position: absolute;
  font-size: 1.2em;
  right: 2px;
}

.fa-check-circle {
  
  color: $green;
  visibility: hidden;
}

.fa-times-circle {
  color: $red;
  visibility: hidden;
}
              
            
!

JS

              
                let validName = false;
let validEmail = false;
let validPassword = false;

let emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

function checkName() {
  let thisName = document.getElementById('fullName').value;
  
  if (thisName == "") {
    validName = false;
    
    document.getElementById('nameCheck').style.visibility = "hidden";
    document.getElementById('nameX').style.visibility = "visible";
  } else {
    validName = true;

    document.getElementById('nameError').style.visibility = "hidden";
    document.getElementById('nameCheck').style.visibility = "visible";
    document.getElementById('nameX').style.visibility = "hidden";
  }
}

function checkEmail() {
  let thisEmail = document.getElementById('email').value;
  
  if (thisEmail == "") {
    validEmail = false;
    
    document.getElementById('emailError').innerHTML = "Email address is required.";
    document.getElementById('emailCheck').style.visibility = "hidden";
    document.getElementById('emailX').style.visibility = "visible";
  } else if (thisEmail != "" && emailRegex.test(thisEmail) == false) {
    validEmail = false;
    
    document.getElementById('emailError').innerHTML = "Invalid email format.";
    document.getElementById('emailCheck').style.visibility = "hidden";
    document.getElementById('emailX').style.visibility = "visible";
  } else {
    validEmail = true;

    document.getElementById('emailCheck').style.visibility = "visible";
    document.getElementById('emailX').style.visibility = "hidden";
  }
}

function checkPassword() {
  let thisPassword = document.getElementById('password').value;
  let passwordLength = thisPassword.length;
  
  if (thisPassword == "") {
    validPassword = false;
    
    document.getElementById('passwordError').innerHTML = "Password is required.";
    document.getElementById('passwordX').style.visibility = "visible";
  } else {
    
    if (thisPassword.length < 8) {
      validPassword = false;
      
      document.getElementById('passwordError').innerHTML = "Password is too short.";
      document.getElementById('passwordCheck').style.visibility = "hidden";
      document.getElementById('passwordX').style.visibility = "visible";
    } else if (thisPassword.length > 21) {
      validPassword = false;
      
      document.getElementById('passwordError').innerHTML = "Password is too long.";
      document.getElementById('passwordCheck').style.visibility = "hidden";
      document.getElementById('passwordX').style.visibility = "visible";
    } else {
      validPassword = true;
      
      document.getElementById('passwordCheck').style.visibility = "visible";
      document.getElementById('passwordX').style.visibility = "hidden";
    }
    
  }
}

function displayNameErrorMsg() {
  document.getElementById('nameError').style.visibility = "visible";
}

function hideNameErrorMsg() {
  document.getElementById('nameError').style.visibility = "hidden";
}

function displayEmailErrorMsg() {
  document.getElementById('emailError').style.visibility = "visible";
}

function hideEmailErrorMsg() {
  document.getElementById('emailError').style.visibility = "hidden";
}

function displayPasswordErrorMsg() {
  document.getElementById('passwordError').style.visibility = "visible";
}

function hidePasswordErrorMsg() {
  document.getElementById('passwordError').style.visibility = "hidden";
}

function handleButton() {
  
  checkName();
  checkEmail();
  checkPassword();
  
  if (validName && validEmail && validPassword) {
    console.log("The form is valid and will be submitted.");
  } else {
    console.log("Information will not be submitted.");
  }
  
}
              
            
!
999px

Console