ExampleDisplay an alert when a form is submitted:
Try it yourself » |
The submit event occurs when a form is submitted.
This event can only be be used on form elements.
The submit() method triggers the submit event, or if the function parameter is set, it specifies what happens when a submit event occurs.
Trigger the submit event for the selected element.
|
Try it yourself » |
Specifies a function to run when the submit event is triggered for the selected element.
|
Try it yourself » |
Parameter | Description |
---|---|
function | Optional. Specifies the function to run when the submit event is triggered. |
![]() |
Try it Yourself - Examples |
Prevent the default action of a submit button
How to prevent the form being submitted using the events preventDefault() method.