onsubmit Attributeonsubmit AttributeThe onsubmit attribute may be used on
a form element
to specify script to be executed when a Submit button for the
form is activated. Note:
The onsubmit handler
is not invoked if the form is submitted by
using the JavaScript method Form.submit().
If the onsubmit script returns
false then the form will not be submitted
(in script-enabled user agents) so it is useful for form data validation.
See also the onreset and
onclick attributes.
If you use this attribute (or any attributes of Type Script) the MIME type of the scripting language used should always be provided in a Content-Script-Type HTTP header.
It is good practice not to use these attributes, however,
and instead to include external scripts (via
script elements)
which add any handlers unobtrusively. This makes code more self-contained and
also the XHTML is easier to maintain if it doesn't contain any events attributes.