Pen Settings



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


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


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.


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.


                <form name="myform">
  <label for="name">Name</label>
  <input name="name" type="text" onchange="validateOneInput(this)"/>
  <p id="errorMessage-name"></p>
  <label for="email">Email</label>
  <input name="email"  type="email" onchange="validateOneInput(this)"/>
  <p id="errorMessage-email"></p>
  <label for="website">Website</label>
  <input name="website" type="url" onchange="validateOneInput(this)"/>
  <p id="errorMessage-website"></p>

  <input type="button" value="submit" name="submit" onclick="submitForm()"/>



                [id^="errorMessage"] {
  color: red;
  font-size: 0.7rem;
  margin: 0 1rem;
input, p, label {
  font-size: 1rem;
  font-family: Helvetica, sans-serif;
input {
  box-sizing: border-box;
  padding: 0.5rem;
  margin: 1rem 1rem 0 1rem;
p {
  width: 500px;
label {
  display: block;


function clearError(el) {
  document.getElementById("errorMessage-" + = "";

function validateOneInput(el) {
  if (!el.value) {
    // display each error under input field
    document.getElementById("errorMessage-" + =
      'The "' + + '" field is empty';
    return false;
  } else if ( == "email" && el.value.indexOf("@") < 1) {
    // check for example if email field contains @ character
    document.getElementById("errorMessage-email").innerHTML =
      'The "email" field is invalid';
    return false;
  return true;

function validate(el) {
  const form = document.forms["myform"];
  // add flag for error messages
  let validated = true;

  // check each of the field if any of them is empty
  for (let i = 0; i < form.length; i++) {
    // check individually all form elements except for submit input
    if (form[i].name !== "submit" && !validateOneInput(form[i])) {
      validated = false;
  return validated;

function submitForm() {
  if (validate()) {
    window.alert("form can be submitted");
  } else {
    window.alert("form can not be submitted");