cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <p class="contact-no-js message">You must have Javascript enabled to use this contact form.</p>
<p class="contact-submitted hidden">Your message was sent.</p>
<p class="contact-error hidden">There was an error sending the message.</p>

<form class="contact-form hidden" action="#" method="post" accept-charset="UTF-8">
  <label for="edit-name">Name</label>
  <input type="text" id="edit-name" name="name" placeholder="Your name" tabindex="1" required autofocus><span></span>
  <label for="edit-mail">E-mail address</label>
  <input type="email" id="edit-mail" name="email" placeholder="Your e-mail address" tabindex="2" required><span></span>
  <input type="text" id="edit-url" class="hidden" name="url" placeholder="Skip if you are a human">
  <label for="edit-subject">Subject</label>
  <input type="text" id="edit-subject" name="subject" placeholder="A short subject" tabindex="3" required><span></span>
  <label for="edit-message">Message</label>
  <textarea id="edit-message" name="message" rows="5" placeholder="The messages goes here…" tabindex="4" required></textarea><span></span>
  <button type="submit" name="submit" class="form-submit" disabled>Send message</button>
</form>


            
          
!
            
              .contact-form {
  input,
  textarea {
    margin-bottom: .5rem;
    font: inherit;
    width: 95%;
    &:required+span::after {
      content: ' *';
      color: red;
      vertical-align: top;
    }
    &:not(:placeholder-shown):valid {
      background-color: #f4feee;
    }
    &:not(:placeholder-shown):invalid {
      background-color: #fff0f0;
    }
  }
  label,
  button {
    display: block;
  }
 }

.js-submitted {
  input,
  textarea {
    &:valid {
      background-color: #f4feee;
    }
    &:invalid {
      background-color: #fff0f0;
    }
  }
}

.hidden {
  display: none;
}

body {
  margin: .5rem;
  font-size: 18px;
}


            
          
!
            
              'use strict';

// Contact form.
$('.contact-form').each(function() {
  var $contact_form = $(this);
  var $contact_button = $contact_form.find('.form-submit');
  var contact_action = '/php/contact.php';

  // Display the hidden form.
  $contact_form.removeClass('hidden');
  // Remove the "no javascript" messages
  $('.contact-no-js').detach();

  // Wait for a mouse to move, indicating they are human.
  $('body').mousemove(function() {
    // Unlock the form.
    $contact_form.attr('action', contact_action);
    $contact_button.attr('disabled', false);
  });

  // A tab or enter key pressed can also indicate they are human.
  $('body').keydown(function(e) {
    if ((e.keyCode == 9) || (e.keyCode == 13)) {
      // Unlock the form.
      $contact_form.attr('action', contact_action);
      $contact_button.attr('disabled', false);
    }
  });

  // Mark the form as submitted.
  $contact_button.on('click touchstart MSPointerDown', function() {
    $contact_form.addClass('js-submitted');
  });

  // Display messages.
  if (location.search.substring(1) != '') {
    switch (location.search.substring(1)) {
      case 'submitted':
        $('.contact-submitted').removeClass('hidden');
        break;

      case 'error':
        $('.contact-error').removeClass('hidden');
        break;
    }
  }
});


            
          
!
999px
Loading ..................

Console