jQuery Event - submit() Method

Example

Display a warning box when the form is submitted:

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

Try it yourself

Definition and Usage

A submit event occurs when a form is submitted.

This event is only applicable to form elements.

The submit() method triggers the submit event or specifies a function to be executed when a submit event occurs.

Trigger the submit event

Syntax

$(selector).submit()

Try it yourself

Bind a function to the submit event

Syntax

$(selector).submit(function)
Parameters Description
function Optional. Specifies a function to be executed when a submit event occurs.

Try it yourself

More examples

Prevent the default action of the submit button
Use the preventDefault() function to prevent the submission of a form.