jQuery Submit Event

Beginner
5 min read
Updated: Nov 2026
3 examples
Form Events

Definition

The submit event fires when the user attempts to submit a form — click a submit button, press Enter in certain fields, or call .trigger("submit"). Bind with .on("submit", handler) (jQuery 1.7+). The handler runs before the browser navigates or posts.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$("#target").on("submit", function (event) {
  // runs before the form posts / navigates
  event.preventDefault(); // stop the default submit
});

$("#other").on("click", function () {
  $("#target").trigger("submit"); // run handlers (+ default unless prevented)
});

// Prefer this over deprecated .submit(handler)
CallWhat it does
<form>Only element type that receives submit
handlerfunction(event) — runs before default submit
eventDataExtra data available as event.data
preventDefaultCancel navigation for validation / AJAX

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Bind with .on("submit", handler) on a <form>.
Step 2Optionally pass eventData: .on("submit", data, handler).
Step 3Call event.preventDefault() to stop the browser from posting/navigating.

Return Value

Return ValueDescription
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.

jQuery Examples

Example 1 — Basic .on("submit") + preventDefault

Official pattern: run a handler when #target is submitted, then stop navigation.

jQuery
$("#target").on("submit", function (event) {
  $("#out").text("Handler for submit called.");
  event.preventDefault();
});
Try It Yourself

How It Works

  1. Bind. .on("submit", fn) registers the callback on the form.
  2. Submit. Button click or Enter fires the event.
  3. Handler. Your code runs before the browser posts.

Example 2 — Trigger Submit from a Button

Official pattern: #other calls .trigger("submit") — handlers run (and default submit unless prevented).

jQuery
$("#target").on("submit", function (event) {
  $("#out").text("Submit handler ran (user or trigger).");
  event.preventDefault();
});

$("#other").on("click", function () {
  $("#target").trigger("submit");
});
Try It Yourself

How It Works

  1. Bind. The submit handler is ready on #target.
  2. Click. The outer button runs .trigger("submit").
  3. Handler. Bound callbacks run as if the form was submitted.

Example 3 — Validate Before Allowing Submit

Official demo idea: only allow submit when the value is "correct".

jQuery
$("#demo").on("submit", function (event) {
  if ($("#code").val() === "correct") {
    $("#out").text("Validated...");
  } else {
    $("#out").text("Not valid!");
  }
  event.preventDefault(); // demo stays on page; omit to allow a real post
});
Try It Yourself

How It Works

  1. Submit. The form fires submit first.
  2. Check. Read the field value in the handler.
  3. Pass. Valid input can continue (or you still prevent and send AJAX).

Frequently Asked Questions

The submit event fires when the user attempts to submit a form — by clicking a submit button, pressing Enter in certain fields, or calling .trigger("submit"). It can only be attached to form elements. Bind with .on("submit", handler) since jQuery 1.7. The handler runs before the browser navigates or sends the request.
Call event.preventDefault() inside your submit handler, or return false from the handler. Both cancel the default submission so the page does not reload. Use this for client-side validation and AJAX submits.
click fires on the button. submit fires on the form for every submission path — including Enter key submits. Bind submit on the form for validation that covers all paths; bind click only for button-specific behavior.
Browser behavior varies. Enter may submit when there is one text field, when a submit button is present, or under other rules. Do not rely on a specific Enter behavior unless you observe keypress yourself. The submit handler still runs whenever the browser submits.
Call $("#myForm").trigger("submit"). Bound handlers run, and unless you preventDefault, the browser also performs the default submit action. Use this from a custom button outside the form.
Prefer .on("submit", handler) and .trigger("submit"). The .submit() shorthand binding form is deprecated since jQuery 3.3. See the .submit() method tutorial for migration details.

Next: .submit() Method

Learn the deprecated shorthand for bind/trigger submit — and how to migrate it.

.submit() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful