HTML Form Validation — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the HTML Form Validation lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Require a field
easy10 minMake the email field required.
- 2
Validate with a pattern
easy10 minRequire a 5-digit code using pattern.
- 3
Set a minimum
easy10 minRequire a number of at least 1.
- 4
Set a maximum
easy10 minCap the number at 10.
- 5
Combine validation rules
medium10 minRequire an email field with a minimum length.
Find the bug(5)
- 1
Fix validation left to JavaScript only
easy8 minThe field has no required attribute at all.
- 2
Fix the wrong pattern attribute
easy8 minThe attribute is pattern, not regex.
- 3
Fix min used on a text field
easy8 minmin only applies to numeric and date inputs.
- 4
Fix the swapped bounds
easy8 minThe maximum is smaller than the minimum.
- 5
Fix the wrong length attribute
easy8 minA minimum length uses minlength.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace