Programming in HTML5 with JavaScript and CSS3 — Question 28
You are developing a customer contact form that will be displayed on a page of a company's website. The page collects information about the customer.
If a customer enters a value before submitting the form, it must be a valid email address.
You need to ensure that the data validation requirement is met.
What should you use?
Answer options
- A. <input name="email" type="input" required="required"/>
- B. <input name=email" type="url" required="email"/>
- C. <input name="email" class" email"/>
- D. <input name="email" type="email"/>
Correct answer: D
Explanation
The correct answer is D because using type="email" ensures that the browser will validate the input as a proper email format before submission. Option A uses type="input" which does not enforce any specific format, B uses type="url" incorrectly for email validation, and C has a syntax error with class" email" that prevents it from functioning correctly.