Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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="container">
	<div class="row">
		<div class="form-box">
        <h1>Form <span>Registration</span></h1>
    	    <form role="form" id="contact-form">
            <!-- name field -->
                <div class="form-group">
                <div id="nameError" class="sr-only" role="alert"></div>
                <label for="form-name-field" class="sr-only">Name</label>
                    <div class="input-group">
                        <div class="input-group-addon"><span class="glyphicon glyphicon-user"></span></div>
                        <input type="text" class="form-control" id="form-name-field" value="" placeholder="Name">
                    </div>
                </div>
            <!-- email field -->
                <div class="form-group">
                <div id="emailError" class="sr-only"" role="alert"></div>
                <label for="form-email-field" class="sr-only">Email</label>
                    <div class="input-group">
                        <div class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></div>
                        <input type="email" class="form-control" id="form-email-field" value="" placeholder="Email">
                    </div>
                </div>
            <!-- phone field -->
                <div class="form-group">
                <div id="phoneError" class="sr-only"" role="alert"></div>
                <label for="form-phone-field" class="sr-only">Phone</label>
                    <div class="input-group">
                        <div class="input-group-addon"><span class="glyphicon glyphicon-phone"></span></div>
                        <input type="tel" class="form-control" id="form-phone-field" value="" placeholder="Phone">
                    </div>
                </div>
            <div class="checkbox">
                <label>
                    <input type="checkbox" id="checkbox-form"> I agree to terms and condition.
                </label>
              <div id="term-field" class="well">
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut orci quam. Nam vel ligula et mi commodo tincidunt. Cras mi ex, mollis eu magna eu, iaculis dignissim sapien. Donec et arcu malesuada, molestie erat in, tempor quam.</p>
              </div>
            </div>
            <button type="submit" class="btn btn-default">Submit</button>
    	    </form>   
		</div>
	</div>
</div>
              
            
!

CSS

              
                @import "compass/css3";

body {
    background-color: lightblue;
}

.form-box {
    width: 50%;
    margin: auto;
    padding-top:20px;
}

.form-box h1 {
    text-align: center;
    font-weight: bold;
    text-transform: uppercase;
    color: tomato;
}

.form-box h1 span {
    font-weight: lighter;
}
              
            
!

JS

              
                document.getElementById("contact-form").onsubmit = function() {
    //Validate Name
    if(document.getElementById("form-name-field").value === "") {
        document.getElementById("nameError").innerHTML = "Invalid Name! Please try again.";
        document.getElementById("nameError").className = "alert alert-danger";
        document.getElementById("nameError").style.display = "block";
    }
  //Validate Email
   if(document.getElementById("form-email-field").value === "") {
        document.getElementById("emailError").innerHTML = "Invalid Email! Please try again.";
        document.getElementById("emailError").className = "alert alert-danger";
        document.getElementById("emailError").style.display = "block";
    }
  //Validate Phone
   if(document.getElementById("form-email-field").value == "") {
        document.getElementById("phoneError").innerHTML = "Invalid Phone Number! Please try again.";
        document.getElementById("phoneError").className = "alert alert-danger";
        document.getElementById("phoneError").style.display = "block";
    }
 }
document.getElementById("term-field").style.display = "none";
document.getElementById("checkbox-form").onclick = function() {
  if(document.getElementById("checkbox-form").checked) {
    document.getElementById("term-field").style.display = "block";
  } else {
    document.getElementById("term-field").style.display = "none";
  }
}
              
            
!
999px

Console