×

html · level 2 · unit 1 · lesson 3

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

required stops a form until the box is filled.

Add required to an input and the browser will not send the form while that box is empty. It points at the box and shows a message instead.

This checking is called . Until a required box has an answer, the browser treats it as . An email box is invalid too while what is typed has no @.

required needs no value: the word on its own is enough. Tell people as well, by adding (required) to the label, so nobody is caught out.

<form>
  <label for="name">Name (required)</label>
  <input id="name" name="name" required>
  <label for="email">Email (required)</label>
  <input type="email" id="email" name="email" required>
  <button>Book a table</button>
</form>

Press show my page to see it here.

Validation in the browser helps visitors, but the server should still check every answer again.