Make the email field required.
Acceptance criteria
- 1.Make the email field required.
HTML Tutorial · HTML Forms
These 10 tasks go with the HTML Form Validation chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “Form validation ensures that the data entered by a user meets the expected format and requirements before being submitted to the server. It helps maintain data accuracy, prevent errors, and enhance user experience. HTML5 introduced built-in form validation features that work without the need for JavaScript.” .
1.Require a fieldexercise · easy · 10 min
Make the email field required.
Passes when: Make the email field required.
2.Validate with a patternexercise · easy · 10 min · practice plan
Require a 5-digit code using pattern.
Passes when: Require a 5-digit code using pattern.
3.Set a minimumexercise · easy · 10 min · practice plan
Require a number of at least 1.
Passes when: Require a number of at least 1.
4.Set a maximumexercise · easy · 10 min · practice plan
Cap the number at 10.
Passes when: Cap the number at 10.
5.Combine validation rulesexercise · medium · 10 min · practice plan
Require an email field with a minimum length.
Passes when: Require an email field with a minimum length.
6.Fix validation left to JavaScript onlybug fix · easy · 8 min
The field has no required attribute at all.
Passes when: The field has no required attribute at all.
7.Fix the wrong pattern attributebug fix · easy · 8 min · practice plan
The attribute is pattern, not regex.
Passes when: The attribute is pattern, not regex.
8.Fix min used on a text fieldbug fix · easy · 8 min · practice plan
min only applies to numeric and date inputs.
Passes when: min only applies to numeric and date inputs.
9.Fix the swapped boundsbug fix · easy · 8 min · practice plan
The maximum is smaller than the minimum.
Passes when: The maximum is smaller than the minimum.
10.Fix the wrong length attributebug fix · easy · 8 min · practice plan
A minimum length uses minlength.
Passes when: A minimum length uses minlength.
Between them these tasks cover required, pattern, min and max and type validation.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.