diffsnack
HTML Find the mistake Level 10

HTML exercise: Form fields and labels — Find the bug.

The page has no JavaScript, and tapping "Request trial" should submit the booking form above it.

The exercise

Find the bug.

1<form id="booking" action="/book"
2 method="post">
3 <label for="day">Preferred day</label>
4 <input type="date" id="day"
5 name="day" required>
6</form>
7<p>Free 30-minute trial lesson.</p>
8<button type="submit" form="book">
9 Request trial
10</button>

Solution

The bug is in line 8.

- <button type="submit" form="book">
+ <button type="submit" form="booking">

A <button> placed outside a <form> submits that form only when its form attribute matches the form's id exactly. Here form="book" matches no form id, so tapping the button does nothing until it is form="booking".

Play this exercise Learn the concept: Form fields and labels