jQuery submit() Method

jQuery submit() event occurs when a form is submitted. The jQuery submit method triggers the submit event, and when submit event occurs specified function will execute.

jQuery submit() event can be used on <form> elements.

Syntax

This syntax represent to the submit() method

$(selector).submit();        // This syntax does not accept any arguments.

and this syntax represent to attach a function to the submit event

$(selector).submit(function);
Parameter Type Description
function Function Optional. Specifies the function to execute when the submit is occurs

Examples

This example represent the submit event

$(document).ready(function(){
  $("form").submit(function(e){
    alert("Form submitted successfully.");
  });
  $("button").click(function(){
    $("form").submit();
  });
});

Run it...   »


This example represent to attach a function to the submit event.

$(document).ready(function(){
  $("form").submit(function(e){
    alert("Form submitted successfully.");
  });
});

Run it...   »