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

Add the required attribute to the input for the name.

Add the required attribute 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.

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

10/11