Pen Settings



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


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.


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.


                <form class="contact-form">
  <div class="form-layout">
      <span class="label-text">Name</span>
      <input type="text" name="name" required>
      <div class="label-text">E-Mail</div>
      <input type="email" name="email" required />
      <div class="label-text">Betreff</div>
      <input type="text" name="subject"  />
  <div class="error-message"></div>
  <input type="submit" />


                body {
  background-color: #f9f9f9;
  font-family: sans-serif;

.contact-form {
  background-color: #fff;
  box-shadow: 0 0 2px rgba(0,0,0,0.1), 0 10px 30px -10px rgba(0,0,0,0.15);
  padding: 50px;
  max-width: 100%;
  width: 400px;
  margin: 50px auto;
  border-radius: 4px;

.contact-form h1 {
  margin-top: 0;

.contact-form label {
  display: flex;
  flex-direction: column;

.contact-form .label-text {
  margin-bottom: 10px;

.contact-form input {
  padding: 15px 20px;
  border: 2px solid #dfdfdf;
  border-radius: 3px;
  flex-grow: 1;

.contact-form .error-message {
  background-color: #ffdbdb;
  color: #8d0000;
  padding: 15px;
  border-radius: 3px;
  margin-top: 30px;
  display: none;

.contact-form input[type="submit"] {
  background-color: black;
  color: #fff;
  border: none;
  font-weight: bold;
  font-size: 16px;
  margin-top: 30px;
  width: 100%;
  transition: all ease 0.1s;

.contact-form input[type="submit"]:hover {
  background-color: #222;

.contact-form input[type="submit"]:active {
  transform: scale(0.98);
  background-color: #000;

.contact-form input.touched:invalid {
  border-color: #D70909;
  outline-color: #D70909;

.contact-form input.touched:invalid:focus {
  border-color: blue;
  outline-color: blue;

.contact-form .form-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;


                var contactForm = $('.contact-form')
var inputs = $('.contact-form input')
var requiredInputs = $('.contact-form input[required]')
var sendButton = $('.contact-form input[type="submit"]')
var errorMessage = $('.error-message')

function hasInvalidInputs() {
   return $('.contact-form input:invalid').length > 0

function showErrorMessage(message) {
  errorMessage.css('display', 'block')

function hideErrorMessage() {
   errorMessage.css('display', 'none')

sendButton.on('click', function() {
  if(hasInvalidInputs() == true) {
    var message = 'Diese Felder sind ungültig: '
    var invalidFieldNames = []
    $('.contact-form input:invalid').each(function() {
      var currentInvalidField = $(this)
    message = message + invalidFieldNames.join(', ')
//    showErrorMessage(' Einige Felder sind ungültig. Bitte korrigieren Sie die Felder und versuchen Sie es erneut!')
    // fehlermeldung die bereits im html drin ist anzeigen
  } else {

contactForm.on('submit', function(e) {
  alert('Jetzt würde das Formular abgesendet werden!')

inputs.on('blur', function(e) {
  if(hasInvalidInputs() == false) {

requiredInputs.each(function() {
  var currentInput = $(this)
  var labelForCurrentInput = currentInput.parent()
  var labelText = labelForCurrentInput.find('.label-text')
  labelText.append('<span style="color: red; margin-left: 5px; font-size: 20px;">*</span>')