1.7 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			1.7 KiB
		
	
	
	
	
	
	
	
id, title, challengeType, videoUrl, forumTopicId, localeTitle
| id | title | challengeType | videoUrl | forumTopicId | localeTitle | 
|---|---|---|---|---|---|
| bad87fee1348bd9aedc08830 | Use HTML5 to Require a Field | 0 | https://scrimba.com/p/pVMPUv/cMd4EcQ | 18360 | 给表单添加一个必填字段 | 
Description
input元素中加上 required 属性就可以了,例如:<input type="text" required>
Instructions
input元素加上required属性,这样用户就必须先在输入框里填入内容,然后才可以提交表单。
Tests
tests:
  - text: '<code>input</code>元素必须有<code>required</code>属性。'
    testString: assert($("input").prop("required"));
Challenge Seed
<h2>CatPhotoApp</h2>
<main>
<p>点击查看更多<a href="#">猫咪图片</a>。</p>
  
  <a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="一只仰卧着的萌猫"></a>
  
  <p>猫咪最喜欢的三件东西:</p>
  <ul>
    <li>猫薄荷</li>
    <li>激光笔</li>
    <li>千层饼</li>
  </ul>
  <p>猫咪最讨厌的三件东西:</p>
  <ol>
    <li>跳蚤</li>
    <li>打雷</li>
    <li>同类</li>
  </ol>
  <form action="https://freecatphotoapp.com/submit-cat-photo">
    <input type="text" placeholder="猫咪图片地址">
    <button type="submit">提交</button>
  </form>
</main>