--- id: bad87fee1348bd9aedc08830 title: Use HTML5 to Require a Field challengeType: 0 videoUrl: '' localeTitle: 使用HTML5需要字段 --- ## Description
您可以订定必填项,限制您的用户在完成必填项之前无法提交表单。如果您要订定必填项段,只需在input元素中添加required的属性,如下所示: <input type="text" required>
## Instructions
利用required 使您的input成为必填项 ,限制您的用户在沒填写必填项的情况下无法提交表单。请尝试在沒有在完成必填项前提交表单,看看HTML5如何通知您少填了必填项。
## Tests
```yml tests: - text: 您的input元素应具有required属性。 testString: 'assert($("input").prop("required"), "Your text input element should have the required attribute.");' ```
## Challenge Seed
```html

CatPhotoApp

Click here to view more cat photos.

A cute orange cat lying on its back.

Things cats love:

  • cat nip
  • laser pointers
  • lasagna

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats
```
## Solution
```js // solution required ```