HTML and CSS Reference
In-Depth Information
Quiz
1. What happens whenever a user clicks a link, button, or form element on a web
page?
2. In an event handler, what does this refer to?
3. What kinds of nodes on a page can be associated with properties like nextChild
and previousChild ?
4. How does form validation with JavaScript conserve server resources?
15
Quiz Answers
1. Whenever a user clicks a link, a button, or any form element, the browser generates
an event signal that can be captured by one of the event handlers mentioned in the
previous lesson.
2. In event handlers, this is a reference to the element on which the event was called.
So in an event handler for the onclick event of a link, this would refer to the link
that the user clicked on.
3. Nodes in the DOM can include HTML elements, text inside HTML elements, and
even whitespace between elements.
4. JavaScript enables you to do error checking in forms on the browser side before
the form is ever submitted to the server. A script must access the server before it
can determine the validity of the entries on a form. (Note that even if you use
JavaScript form validation you must validate user input on the server, too, because
users can bypass the JavaScript if they choose.)
Exercises
1. Change the HTML validation example to add error messages to the page above the
form when validation fails.
2. Add a Preview button to the form validation example that displays the values the
user entered below the form.
3. Modify the FAQ example so that users can click a link for each question to remove
that question from the page entirely.
 
Search WWH ::




Custom Search