Event Handlers

The XHTML 1.0 recommendation also allows for several event handlers that can be used to trigger the execution of script code embedded in an XHTML document. Each event handler is tied to a specific event that can occur during a person's use of a browser. When a user submits a form, for example, you can capture that event and launch a field validation script using the onsubmit event handler:

<form action="register.cgi" method="post" onsubmit="return validate();">

▸ For the specifics on writing scripts for your HTML documents, see Chapter 18, "Introduction to JavaScripting," or Chapter 32, "Writing Active Server Pages"

Thus, when a user clicks the Submit button, the scripted function named validate() executes and checks the data ...

Get Platinum Edition Using XHTML™, XML, and Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.