2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								id: bad87fee1348bd9aedd08830
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								title: Add a Submit Button to a Form
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								challengeType: 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								videoUrl: 'https://scrimba.com/p/pVMPUv/cp2Nkhz'
							 
						 
					
						
							
								
									
										
										
										
											2019-07-31 11:32:23 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								forumTopicId: 16627
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Description
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< section  id = 'description' > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Let's add a < code > submit< / code >  button to your form. Clicking this button will send the data from your form to the URL you specified with your form's < code > action< / code >  attribute.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Here's an example submit button:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< code > & #60 ; button type="submit"& #62 ; this button submits the form& #60 ; /button& #62 ; </ code > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / section > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Instructions
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< section  id = 'instructions' > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Add a button as the last element of your < code > form< / code >  element with a type of < code > submit< / code > , and "Submit" as its text.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / section > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Tests
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< section  id = 'tests' > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```yml
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								tests:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  -  text: Your form should have a button inside it.
							 
						 
					
						
							
								
									
										
										
										
											2019-07-24 02:50:51 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    testString: assert($("form").children("button").length > 0);
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  -  text: Your submit button should have the attribute < code > type</ code >  set to < code > submit</ code > .
							 
						 
					
						
							
								
									
										
										
										
											2019-07-24 02:50:51 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    testString: assert($("button").attr("type") === "submit");
							 
						 
					
						
							
								
									
										
										
										
											2020-08-31 04:53:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  -  text: Your submit button should only have the text < code > Submit</ code > .
							 
						 
					
						
							
								
									
										
										
										
											2019-07-24 02:50:51 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    testString: assert($("button").text().match(/^\s*submit\s*$/gi));
							 
						 
					
						
							
								
									
										
										
										
											2019-11-20 06:45:19 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  -  text: Your < code > button</ code >  element should have a closing tag.
							 
						 
					
						
							
								
									
										
										
										
											2019-07-24 02:50:51 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    testString: assert(code.match(/< \/button > /g) &&  code.match(/< button / g )  &&  code . match (/< \/button > /g).length === code.match(/< button / g ). length ); 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / section > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Challenge Seed
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< section  id = 'challengeSeed' > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< div  id = 'html-seed' > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```html
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< h2 > CatPhotoApp< / h2 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< main > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < p > Click here to view more < a  href = "#" > cat photos< / a > .< / p > 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-08 01:01:53 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  < a  href = "#" > < img  src = "https://bit.ly/fcc-relaxing-cat"  alt = "A cute orange cat lying on its back." > < / a > 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-08 01:01:53 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  < p > Things cats love:< / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < ul > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < li > cat nip< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < li > laser pointers< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < li > lasagna< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < / ul > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < p > Top 3 things cats hate:< / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < ol > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < li > flea treatment< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < li > thunder< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < li > other cats< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < / ol > 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-15 02:56:49 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  < form  action = "https://freecatphotoapp.com/submit-cat-photo" > 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    < input  type = "text"  placeholder = "cat photo URL" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < / form > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / main > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / section > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Solution
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< section  id = 'solution' > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-02-15 00:58:40 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```html
							 
						 
					
						
							
								
									
										
										
										
											2018-11-06 21:44:23 +05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								< h2 > CatPhotoApp< / h2 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< main > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < p > Click here to view more < a  href = "#" > cat photos< / a > .< / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < a  href = "#" > < img  src = "https://bit.ly/fcc-relaxing-cat"  alt = "A cute orange cat lying on its back." > < / a > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < p > Things cats love:< / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < ul > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < li > cat nip< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < li > laser pointers< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < li > lasagna< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < / ul > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < p > Top 3 things cats hate:< / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < ol > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < li > flea treatment< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < li > thunder< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < li > other cats< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < / ol > 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-15 02:56:49 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  < form  action = "https://freecatphotoapp.com/submit-cat-photo" > 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-06 21:44:23 +05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    < input  type = "text"  placeholder = "cat photo URL" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < button  type = "submit" > Submit< / button > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < / form > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / main > 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2019-02-15 00:58:40 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								< / section >