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.

            
                <div class="form-wrap">
    <form action="#submit" method="post" class="validate go-bottom">

      <!-- First name -->
      <div class="column half">
          <input type="text" id="firstname" name="firstname" required />
        <label for="firstname">
          Your First Name
        </label>
      </div>

      <!-- Last Name -->
      <div class="column half last">
        <input type="text" id="lastname" name="lastname" required />
        <label for="lastname">
          Your Last Name
        </label>
      </div>

      <!-- Email -->
      <div class="column half">
        <input type="email" id="email" name="email" required />
        <label for="email">
          Your Email
        </label>
      </div>

      <!-- Phone -->
      <div class="column half last">
        <input type="tel" id="phone" name="phone" required />
        <label for="phone">
          Your Phone
        </label>
      </div>

      <!-- Message -->
      <div class="column full">
        <textarea id="message" name="message" rows="5" required></textarea>
        <label for="message">
          Message
        </label>
      </div>

      <!-- Submit -->
      <div class="column submit">
        <button type="submit" id="submit" name="submit" class="btn_blue">Submit</button>
      </div>

    </form>
  </div>

            
          
!
            
              *, *::before, *::after {
    box-sizing: border-box;
}

*:focus {
    outline: none;
}

body {
  background: IndianRed;
}

.column {
	
	&.half {
		width: calc(50% - 30px);
		float: left;
	}
	
	&.half.last {
		margin-left: 60px;
	}
	
	&.full {
		width: 100%;
		clear: both;
		float: left;
	}
	
}


.form-wrap {
	font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
	padding: 60px 0;
  max-width: 1000px;
	width: auto;
  margin: auto;	

	form {

		> div {
			position: relative;
			overflow: visible;
			margin-bottom: 60px;
		}

		input, textarea {

			&:focus + label {
				font-size: 14px !important;
				padding: 1px 6px;
				z-index: 2;
	    	}

		}

		input {
      background: none;
			border: solid 3px #FFF;
			color: #FFF;
			font-size: 20px;
			padding: 15px;
			height: auto;
      width: 100%;
			z-index: 1;

			&.invalid {
				border: solid 3px #ff0000;
				position: relative;
				background: none;

				&:hover {

					+ span.invalid {
				    	opacity: 1 !important;
				    	position: absolute;
				    	width: 200px;
				    	font-size: 14px;
				    	right: 0;
				    	top: 0;
				    	padding: 6px 10px;
				    	background: #FF0000;
				    	color: #FFF;
				    	text-align: center;
				    	z-index: 0;
			    	}

				}

			}

		}

		textarea {
      background: none;
			width: 100%;
			resize: none;
			border: solid 3px #FFF;
			color: #FFF;
			font-weight: 500;
			padding: 25px;
      resize: none;
			z-index: 1;

			&.invalid {
				border: solid 3px #ff0000;
				position: relative;

				&:hover {

					+ span.invalid {
				    	opacity: 1 !important;
				    	position: absolute;
				    	width: 200px;
				    	font-size: 14px;
				    	right: 0;
				    	top: 0;
				    	padding: 6px 10px;
				    	background: #FF0000;
				    	color: #FFF;
				    	text-align: center;
				    	z-index: 0;
			    	}

				}

			}

		}

		label {
			font-weight: 500;
			color: #FFF;
			font-size: 20px;
			text-transform: uppercase;
			height: 20px;
	    	transition: // not padding
				background 0.2s,
				color 0.2s,
				top 0.2s,
				bottom 0.2s,
				right 0.2s,
				left 0.2s;
			position: absolute;
			padding: 17px 25px;
			margin: 0;
		}

		textarea {
	    	display: block;
			  resize: vertical;
		}

		&.go-bottom {

			label {
		    top: 0;
				bottom: 0;
				left: 0;
				width: 100%;
			}

			input:focus + label, textarea:focus + label {
		    	top: -30px;
		    	color: #FFF;
			}

			input:valid + label, textarea:valid + label,
			input.invalid ~ label, textarea.invalid ~ label,
			input.valid ~ label, textarea.valid ~ label {
				top: -30px;
				font-size: 14px !important;
				padding: 1px 6px;
				z-index: 2;
				color: #FFF;
	    	}

	    	span.invalid {
		    	opacity: 0 !important;
		    	position: absolute;
		    	right: 0;
				  top: 0;
	    	}

		}

		.confirm.error,
		.alert.invalid {
			margin: 0;
			color: #ff0000;
			font-weight: 400;
	
			i {
				font-style: italic;
			}
		}
		.invalid,
		.error {
			margin: 0;
			color: #ff0000;
		}
		.submit {
			float: left;
			width: 100%;
			text-align: center;
      clear: both;
			
			button {
				background: rgba(0, 0, 0, 1);
				width: 330px;
				font-size: 20px;
				border: none;
				color: #FFF;
				margin: 0;
				float: none;
				padding: 22px 10px;
        text-transform: uppercase;
        transition: 0.5s;
        cursor: pointer;
        
        &:hover {
          background: rgba(0, 0, 0, 0.5);  
        }
        
			}
			
		}
	    
		.alert {
			margin: 20px 0 0;
		}
		
	}
	
}
            
          
!
            
              /* ==============================
Form validation
============================== */
$( 'form.validate' ).on( 'submit', function() {
    if( !$( this ).valid() ) {
        var me = $( this ),
            msg = me.find( '.alert' ).attr( 'data-msg' );

            me.find( '.alert' )
                .text( msg )
                .addClass( 'invalid show' );

        return false;
    }
});


$( 'form.validate' ).validate({
    rules: {
        firstname: {
            required: true,
            rangelength: [2, 100]
        },
        lastname: {
            required: true,
            rangelength: [2, 100]
        },
        email: {
            required: true,
            new_email: true
        },
        phone: {
            required: true,
            new_phone: true
        },
        message: {
            required: true,
            minlength: 2
        }
    },
    errorElement: 'span',
    errorClass: 'invalid',
    messages: {
        required: $( this ).attr( 'data-msg' )
    }
});

jQuery.validator.addMethod( 'new_email', function( value, element ) {
    return this.optional( element ) || /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/.test( value );
});

jQuery.validator.addMethod( 'new_phone', function( value, element ) {
    return this.optional( element ) || /^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/.test( value );
});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console