Make the fields required

This form accepts nothing at all as an answer.

What to build

The same form, where both fields must be filled in.

Requirements

  • Both inputs have the required attribute.
  • The name input has minlength="2".

Constraints

Do not change the names.

Example

<input name="city" required>

Why it works

The browser refuses to submit, and points to the first problem field, until each rule is met.

Hints

Hint 1

required is a boolean attribute. It needs no value.

Solution

Show one correct solution (try it yourself first)
<form>
  <label for="n">Name</label>
  <input id="n" name="name" required minlength="2">
  <label for="e">Email</label>
  <input id="e" name="email" type="email" required>
  <button>Send</button>
</form>

Lesson: Checking answers before they are sent →