Pick a Date Range
Write the code, see it run, pass the checks.
The problem
- medium
- Code
- Pro
A booking form has two date inputs (type="date") labelled "Check-in" and "Check-out", and a "Book" button. A date input's value is the date as year-month-day, e.g. "2026-03-10". The button is disabled until both dates are set and Check-out is after Check-in. If both are set but Check-out is the same day or earlier, show "Check-out must be after check-in". When the range is valid, show the number of nights, e.g. "3 nights" (or "1 night" for one). Clicking Book replaces the form with "Booked 3 nights from 2026-03-10" (the nights and the check-in value).
Your code must pass
- Book is disabled until both dates are set
- Check-out on or before check-in shows an error
- A valid range shows the number of nights
- One night is singular
- Book confirms the stay