HTML and CSS Reference
Correct answer: C
Incorrect: You can do this with a custom event, but that's more work than
Incorrect: The goal is to validate the data before submitting the form.
Correct: The required attribute ensures that a field contains a value before being
Incorrect: A label would be informative but doesn't guarantee that all the required
fields are populated before submitting.
Objective 3.2: Thought experiment
The safest approach to restricting input data is to restrict the characters that a user can enter
into a specific field. If a field is designed to accept only numeric data, ensure that the valida-
tion on that input control will allow only numeric data. The same is true for dates, text, and
any other input that a user can freely type into. Regular expressions simplify this type of
validation by verifying that only the expected characters are entered. If a text box is expect-
ing a person's name, don't allow HTML characters such as the < or > symbols to be input into
the field. Also, restrict the field length so that it matches the type of the data expected. A field
expecting the age of a person doesn't need to be 500 characters; you can probably get away
with allowing only 3 characters.
Objective 3.2: Review
Correct answer: A
Correct: The $ sign denotes the end of the string.
Incorrect: The % sign doesn't denote the end of the string.
Incorrect: The ^ character denotes the start of the string.
Incorrect: The & character doesn't denote the end of the string.
Correct answer: D
Incorrect: Allows scripts to run
Incorrect: Only allows content from the same origin
Incorrect: Allows forms
Correct: Allows content from the containing HTML document
Incorrect: Not a valid option