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

              
                <body>
    	<div class="container">
    		<h1>
    			<span class="blue">G</span>
    			<span class="red">i</span>
    			<span class="purple">p</span>
    			<span class="green">h</span>
    			<span class="pink">y</span> <small>Captcha.</small></h1>
	        <form>
	        	<div class="formData">
		        	<div class="formDiv">
		        		<input type="text" required>
			        	<label class="label">Your Name</label>
			        </div>
			        <div class="formDiv">
			        	<input type="text" required>
			        	<label class="label">Email</label>
			        </div>

			        <div class="formDiv">
			        	<div class="checkboxDiv">
				        	<div class="checkbox">
					        	<input type="checkbox" id="checkForRobot">
					        	<label for="checkForRobot"></label>
				        	</div>
				        	<span>I'm not a robot.</span>
				        </div>
			        </div>

			        <div class="captchaDiv close">
			        	<div id="giphy_captcha"></div>
			        	<input type="text" placeholder="What are you seeing? (e.g. cat, dog,  funny)" id="captcha_input" required>
			        	<span>*Describe what you see in the above GIF to prove you're HUMAN. <a href="#" id="reload">Too difficult? Reload GIF</a></span>
			        </div>
			    </div>

		        <button id="submit">
		        	<span class="text">Submit</span>
		        	<div class="spinner">
						<div class="bounce1"></div>
						<div class="bounce2"></div>
						<div class="bounce3"></div>
					</div>
		        </button>
	        </form>
	    </div>
        <script src="js/main.js"></script>
    </body>
              
            
!

CSS

              
                $white: #ffffff;
$grey: #353535;
$dark_grey: #1F2124;
$blue: #2F8BE6;
$green: #1DE9B6;
$base: 1rem;
$font_family: 'Dosis', sans-serif;

//Giphy colors
$giphy_blue: #0cf;
$giphy_pink: #e54cb5;
$giphy_purple: #93f;
$giphy_red: #fc6669;
$giphy_green: #0f9;

%formElementDefault {
	font-family: $font_family;
	font-size: $base;
	letter-spacing: 0.05em;
	box-sizing: border-box;
	outline: 0;
	border-radius: 2px;
}

%input {
	@extend %formElementDefault;
	background: rgba($dark_grey, .5);
	border: 1px solid rgba($white, .1);
	color: white;
	padding: 10px 8px 0;
}
%input-white {
	@extend %input;
	background: $white;
	color: $grey;
	border:none;
}

/* 
	Amazing CSS Spinner from
	http://tobiasahlin.com/spinkit/
*/
.spinner {
  margin: 0 auto;
  width: 70px;
  text-align: center;
  transform: scale(0.5);

  > div {
	width: 18px;
	height: 18px;
	background-color: $white;

	border-radius: 100%;
	display: inline-block;
	animation: sk-bouncedelay 1.4s infinite ease-in-out both;
  }
  .bounce1{
  	animation-delay: -0.32s;
  }
  .bounce2{
  	animation-delay: -0.16s;
  }
}
@keyframes sk-bouncedelay {
  0%, 80%, 100% { 
    transform: scale(0);
  } 40% { 
    transform: scale(1.0);
  }
}

* {
	margin:0;
	padding:0;
}
body {
	background: $grey;
	font-size:16px;
	text-transform: uppercase;
	font-family: $font_family;
	color: $white;
	font-weight: 200;
	letter-spacing: 0.11em;
}
a {
	color: $blue;
}
img {
  max-width: 100%;
}
h1 {
	font-weight: 200;
	text-align:center;
	margin-bottom: 20px;;
	font-size: $base * 2.5;
	letter-spacing: 0.05em;
	>span {
		font-weight: 400;
	}
	.blue {
		color: $giphy_blue;
	}
	.pink {
		color: $giphy_pink;
	}
	.red {
		color: $giphy_red;
	}
	.green {
		color: $giphy_green;
	}
	.purple {
		color: $giphy_purple;
	}
}
.container {
	max-width:600px;
	margin: 50px auto 0;
}

form {
	width:400px;
	margin: 0 auto;
	color: $white;

	.formDiv {
		position:relative;
		margin-bottom: 20px;
	

		.label {
			position:absolute;
			top:50%;
			left:10px;
			transform: translateY(-50%);
			opacity: .3;
			z-index: 2;
			transition: all .5s ease;
		}
		input{
			@extend %input;
			position:relative; 
			z-index: 3;
			&[type="text"] {
				width: 100%;
				height:60px;
				box-shadow: inset 0 0 10px 1px rgba(#000, 0);
				transition: all .5s ease;
				&:focus {
					box-shadow: inset 0 0 10px 2px rgba(#000, .3);
				}
				&:focus ~ .label,
				&:valid ~ .label {
					top:15px;
					font-size: 10px;
					opacity: .8;
					z-index: 4;
				}
			}
			&[type="checkbox"]{
				visibility: hidden;
			}
		}

		.checkboxDiv {
			position:relative;

			.checkbox,
			> span {
				display: inline-block;
				vertical-align: middle;
			}

			.checkbox {
				width: 24px;
				height: 24px;
				position:relative;
				margin-right: 5px;

				label {
					@extend %input;
					position:absolute;
					top:0;
					left:0;
					width: 100%;
					height: 100%;
					transition: all .5s ease;
				}

				input[type="checkbox"]:checked ~ label {
					box-shadow: inset 0 0 3px 2px rgba(#000, .3);
					&:after {
						content: "\f00c";
						font-family: FontAwesome;
						font-size: $base * 0.75;
						position: absolute;
						top: 50%;
						left: 50%;
						transform: translateX(-50%) translateY(-50%);
					}
				}
			}
		}
	}
	
	.captchaDiv {
		overflow-y: hidden;
		max-height: 800px;
		transition: all .8s ease;

		&.close {
			max-height: 0;
		}

		#giphy_captcha {
			background: $dark_grey;
			text-align: center;
			border-radius: 2px 2px 0 0;
			transition:  all .3s linear;
		}
		input[type="text"]{
			@extend %input-white;
			padding-top: 0;
			margin-bottom: 10px;
			width: 100%;
			height: 50px;
		}
		span {
			display: block;
			text-transform: initial;
			margin-bottom: 20px;
		}
	}

	.formData {
		position: relative;
		
		&.disabled {
			&:after {
				content: '';
				position:absolute;
				top:0;
				left:0;
				width: 100%;
				height: 100%;
				background: rgba($grey, .6);
				z-index: 10;
			}
		}
	}
		
}

button {
	@extend %formElementDefault;
	width: 100%;
	height: 60px;
	text-align: center;
	background: $blue;
	color: $white;
	border:none;
	text-transform: uppercase;
	cursor: pointer;
	transition: all .3s linear;

	.spinner {
		display: none;
	}

	&:hover {
		background: darken($blue, 10%);
	}

	&:disabled {
		background: $green;
		cursor: default;
	}
}
              
            
!

JS

              
                var API_KEY = 'dc6zaTOxFJmzC'; //Giphy Public API Key
var URL = 'https://api.giphy.com/v1/gifs/search?api_key='+API_KEY;

var loaded = false;
var formData = {
	q: 'monkeys cats dogs birds',
	limit: 1,
	rating: 'pg',
};
var counter = 0;
var currentSlug = null;

$(document).ready(function(){
	$('#checkForRobot').change(function(){
		if($(this).is(':checked')){
			
			if(!loaded){
				$.ajax({
					url: URL,
					data: formData,
					dataType: 'json',
					success: function(data){
						console.log(data, data.data[0].images.downsized.url);
						var dataObj = data.data[0];
						var imgObj = dataObj.images.downsized;
						var imgSrc = imgObj.url;
						var imgWidth = imgObj.width;
						var imgHeight = imgObj.height;

						
						$('<img src="'+imgSrc+'" width="'+imgWidth+'" height="'+imgHeight+'">').appendTo('#giphy_captcha');
						$('.captchaDiv').toggleClass('close');

						currentSlug = dataObj.slug;
					},
					error: function(error){
						console.log(error);
					},
					complete: function(){
						loaded = true;
					}
				});
			}else {
				$('.captchaDiv').toggleClass('close');
			}
			
		}else {
			$('.captchaDiv').toggleClass('close');
		}
	});

	//reload
	$('#reload').click(function(){
		counter++;

		if(loaded){
			
			if(counter > 0){
				formData['offset'] = counter;
			}

			$.ajax({
				url: URL,
				data: formData,
				dataType: 'json',
				beforeSend: function(){
					$('#giphy_captcha').height($('#giphy_captcha img').height());
					$('#giphy_captcha img').remove();
				},
				success: function(data){
					console.log(data, data.data[0].images.downsized.url);
					var dataObj = data.data[0];
					var imgObj = dataObj.images.downsized;
					var imgSrc = imgObj.url;
					var imgWidth = imgObj.width;
					var imgHeight = imgObj.height;

					$('#giphy_captcha').height(imgHeight);
					$('<img src="'+imgSrc+'" width="'+imgWidth+'" height="'+imgHeight+'">').appendTo('#giphy_captcha');

					currentSlug = dataObj.slug;
				},
				error: function(error){
					console.log(error);
				}
			});
		}
		return false;
	});

	//submit function
	$('#submit').click(function(e){

		var btn = $(this),
			spinner = btn.children('.spinner'),
			text = btn.children('.text');


		if($("form")[0].checkValidity()){
			e.preventDefault();

			text.hide(0);
			spinner.fadeIn();
			
			var captcha_field = $('#captcha_input').val();
			var formatedCurrentSlug = currentSlug != null ? currentSlug.replace(/-/g, ' ') : null;
      
      //This is how validation works.
      //However, `slug` doesn't always describe
      //what the GIF is about so 
      //validation is a bit shaky
      //there should be better ideas ;)
			if(formatedCurrentSlug.indexOf(captcha_field) > -1){
				console.log('validated!');
				spinner.fadeOut(300, function(){
					text.html('Succcess!!!').show(0);
					btn.prop('disabled', true);
					$('.captchaDiv').toggleClass('close');
					$('.formData').addClass('disabled');
				});
			}else {
				spinner.fadeOut(300, function(){
					text.html('Try Again :(').show(0);
				});
				
			}
		}
	});
});
              
            
!
999px

Console