HTML and CSS Reference
9.2.8. The Event Attributes
As for most other elements in a document, the <form> tag honors the
standard mouse and keyboard event-related attributes the compliant
browser will recognize. We describe the majority of these attributes in
Forms have two special event-related attributes: onSubmit and onReset .
The value of each event attribute isenclosed in quotation marksone or a
function references. With onSubmit , the browser executes these com-
mands before it actually submits the form's data to the server or sends
it to an email address.
You may use the onSubmit event for a variety of effects. The most pop-
ular is for a client-side forms-verification program that scans the form
data and prompts the user to complete one or more missing elements.
Another popular and much simpler use is to inform users when a mailto
URL form is being processed via email.
The onReset attribute is used just like the onSubmit attribute, except that
the associated program code is executed only if the user presses a Re-
set button in the form.