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

              
                <div>Javascript alert() method doesnt work for the following: A different origin subframe tried to create a JavaScript dialog. This is no longer allowed and was blocked. See https://www.chromestatus.com/feature/5148698084376576 for more details.</div><br><br>
	<form action = "#">
		<h1>Instructions:<br/>At lease one piece of data has to come in from every input type.</h1>
		<p>Name:</p>
		<input type = "text" name = "fullname" value="Enter Full Name"/>
		<p>Gender:</p>
		<ul>
			<li>Male<input type = "radio" name = "gender" value="male"/></li>
			<li>Female<input type = "radio" name = "gender" value="female"/></li>
		</ul>
		<p>Hobbies:</p>
		<ul>
			<li>Baseball <input type = "checkbox" name = "hobbies[]" value = "baseball" /> </li>  
			<li>Football <input type = "checkbox" name = "hobbies[]" value = "football" /></li>  
			<li>Hockey <input type = "checkbox" name = "hobbies[]" value = "hockey" /></li>
		</ul>
		<p>Favorite Show</p> 
		<select name = "show">
			<option value = "">Choose Below</option>
			<option value = "ATHF">Aqua Teen Hunger Force</option>
			<option value = "Family Guy">Family Guy</option>
			<option value = "Simpsons">Simpsons</option>
		</select>
		<p>Comments:</p>
		<textarea cols = "50" rows = "6" name = "comments">Enter Comments</textarea><br/>
		<input class="nice" type = "submit" name = "submit" value = "Enter Me" />
	</form>
              
            
!

CSS

              
                body{
		text-align:center;
		font-family: Verdana,Arial;
	}
	form {
		display:inline-block;
		
		min-width: 5rem;
		max-width: 30rem;
		

		margin: 2rem auto;
		text-align:left;
		background-color:#eee;
		box-shadow:  0px 0px 10px 1px #000;
		padding: 2rem 2rem 2rem 4rem;
	}
	h1 {
		font-size: .8rem;
		font-style: italic;
		
		font-weight: 400;
	}
	p {
		font-weight: 800;
		margin:1em 0 0 0;
	}
	ul{
		margin: 0;
		padding:0 0.8em;
		list-style-type: none;
	}
	input{
		margin:.5rem;
	}
	input, select, textarea {		
		padding:0 .5em;
	}

	select, textarea {
		margin: 0 .5em;
	}
	textarea{
		width:80%;
	}
	input.nice {
		
		padding:.8em 2rem;
		background-color: #000;
		color: #fff;
		font-size: 1em;
		outline:none;
		cursor: pointer;
	}
              
            
!

JS

              
                /*
*alert() doesnt work any longer for the following:
*A different origin subframe tried to create a JavaScript dialog. This is no longer allowed and was *blocked. See https://www.chromestatus.com/feature/5148698084376576 for more details.
*/

document.forms[0].onsubmit = function(e) {
    	//e.preventDefault();
        let formName = document.forms[0].elements[0].value;
	    let formMale = document.forms[0].elements[1];
	    let formFemale = document.forms[0].elements[2];
	    let formBaseball = document.forms[0].elements[3];
	    let formFootball = document.forms[0].elements[4];
	    let formHockey = document.forms[0].elements[5];
	    let formFavShow = document.forms[0].elements[6].value;
	    let formComments = document.forms[0].elements[7].value;

    	if (formName === "" || formName === "Enter Full Name") {
	        alert("Please complete form");
	        document.forms[0].elements[0].focus();
	        return false;
	    } else if (formMale.checked === false && formFemale.checked === false) {
              alert("Please select gender.");
              document.forms[0].elements[1].focus();
              return false;
	    } else if (formBaseball.checked === false && formFootball.checked === false  && formHockey.checked === false) {
	    	alert("Please select at least one hobbie.");
	    	document.forms[0].elements[3].focus();
            return false;
	    } else if (formFavShow === "") {
	    	alert("Please select a favorite show.");
	    	document.forms[0].elements[6].focus();
	    	return false;
	    } else if (formComments === "" || formComments === "Enter Comments") {
	    	alert("Leave a comment.");
	    	document.forms[0].elements[7].focus();
	    	return false;
	    } else {
	    	confirm("Are you sure you want to submit?");
	    	alert("Thank you!");
	    	return true;
	    }
    };

console.log(document.forms);
              
            
!
999px

Console