Example

Display an alert when a form is submitted:

$("form").submit(function(e){
  alert("Submitted");
});

Try it yourself »

Definition and Usage

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

Trigger the submit event for the selected element.

Syntax

$(selector).submit()
Try it yourself »


Bind a Function to the submit Event

Specifies a function to run when the submit event is triggered for the selected element.

Syntax

$(selector).submit(function)
Try it yourself »

Parameter Description
function Optional. Specifies the function to run when the submit event is triggered.


Examples

Try it Yourself - Examples

Prevent the default action of a submit button
How to prevent the form being submitted using the events preventDefault() method.