Required Input
Some inputs must be filled in: for example, you can't sign up for a course without a name or a password.
<input type="text" name="nickname" id="input-nickname" required>To make an input required, we just add the required attribute. Like the controls attribute of videos, it has no value: it's enough to write it. When the user tries to send the form with a required input empty, the browser doesn't send it and shows a message instead.
Instructions
- 1
Add the
requiredattribute to the input for the name. - 2
Add the
requiredattribute to the input for the password. Then run the code and click Submit without filling anything in: the browser shows a message and doesn't send the form.