--- id: bad87fee1348bd9aedc08830 title: Use HTML5 to Require a Field challengeType: 0 videoUrl: '' localeTitle: 使用HTML5需要字段 --- ## Description
您可以要求特定的表单字段,以便您的用户在填写表单之前无法提交表单。例如,如果要创建所需的文本输入字段,只需在input元素中添加required的属性,如下所示: <input type="text" required>
## Instructions
使您的文本input required字段,以便您的用户无法在不填写此字段的情况下提交表单。然后尝试提交表单而不输入任何文本。了解您的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 ```