Name
Form.onsubmit: event handler invoked when a form is submitted — DOM Level 0
Synopsis
Function onsubmit
Description
The onsubmit property of a
Form object specifies an event-handler function that is invoked when
the user submits a form by clicking on its Submit button. Note that this event handler
is not invoked when the Form.submit(
) method is called.
If the onsubmit handler
returns false, the elements of
the form are not submitted. If the handler returns any other value
or returns nothing, the form is submitted normally. Because the
onsubmit handler can cancel form
submission, it is ideal for performing form data validation.
See Element.addEventListener(
) for another way to register event handlers.
See Also
Element.addEventListener(
), Form.onreset,
Form.submit( ); Chapter 17
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access