jQuery Submit Event

Beginner
7 min read
Updated: Oct 2026
5 examples
Live preview

What Is the submit Event?

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.

Remember
$("#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)
NeedUse
React to form submit.on("submit", fn) on the form
Stop navigation / postevent.preventDefault() or return false
Submit programmatically.trigger("submit")
Send via AJAXpreventDefault + .serialize() / $.post()
Legacy shorthand.submit() ⚠ deprecated 3.3

How to Use submit

Bind on the form, validate or prepare data, then allow or cancel the default submit.

  1. Bind with .on("submit", handler) on a <form>.
  2. Optionally pass eventData: .on("submit", data, handler).
  3. Call event.preventDefault() to stop the browser from posting/navigating.
  4. Trigger with .trigger("submit") from a custom button if needed.
  5. For AJAX, preventDefault, then .serialize() and send with $.post() / $.ajax().
PieceRequired?Role
<form>YesOnly element type that receives submit
handlerFor bindfunction(event) — runs before default submit
eventDataOptionalExtra data available as event.data
preventDefaultOftenCancel navigation for validation / AJAX

Pseudocode

Pseudocode
call form.on("submit", handler)
    → store handler on the form

when user clicks submit / Enter causes submit / .trigger("submit"):
    fire "submit" on form
    call handler(event)
    if handler called preventDefault (or returned false):
        stop browser post / navigation
    else:
        browser submits the form (navigate or POST)

to migrate shorthand:
    .submit(fn) → .on("submit", fn)
    .submit()   → .trigger("submit")

Cheat Sheet

Keep these facts handy while wiring form submit UX.

TopicDetail
Bind$("form").on("submit", handler)
Trigger$("form").trigger("submit")
Cancel defaultevent.preventDefault() or return false
Unbind$("form").off("submit" [, handler])
Target<form> only
vs button clicksubmit covers Enter-key submits too
Since.on("submit") 1.7 · .trigger("submit") 1.0
Legacy shorthand.submit() ⚠ deprecated for binding since 3.3
Name conflictsAvoid input name/id of submit, length, method

Live Preview

Submit the demo form (always prevented here so the page stays), or run an action to .trigger("submit").

You can also use the form Submit button below.

Result
Ready — submit the form or pick an action.

jQuery Examples

Short, copy-ready snippets based on the official jQuery API demos. Open Try It Yourself for a live editor.

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.
  4. Cancel. preventDefault() keeps the page in place.

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.
  4. Default. Without preventDefault, the form would also post.

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).
  4. Fail. Invalid input calls preventDefault().

Example 4 — eventData for a Form Label

Pass shared metadata when the form is submitted.

jQuery
$("#signup").on("submit", { form: "signup" }, function (event) {
  $("#out").text("Submitting " + event.data.form);
  event.preventDefault();
});
Try It Yourself

How It Works

  1. Data. The object becomes event.data.
  2. Submit. Submitting the form fires the handler.
  3. Label. Read event.data.form for shared context.
  4. Cancel. Demo uses preventDefault so the page stays.

Example 5 — Serialize for an AJAX-Style Submit

Stop the default post, then collect fields with .serialize() (ready for $.post).

jQuery
$("#contact").on("submit", function (event) {
  event.preventDefault();
  var data = $(this).serialize();
  $("#out").text("Would send: " + data);
  // $.post("/api/contact", data);
});
Try It Yourself

How It Works

  1. Cancel. preventDefault() stops a full page reload.
  2. Serialize. .serialize() builds a query string from fields.
  3. Send. Pass that string to $.post() or $.ajax().
  4. UX. Update a status area instead of navigating away.

Edge Cases & Pitfalls

Check these before relying on submit handlers in real UIs.

target

Only on <form>

Bind submit on the form, not the button. Button click alone misses Enter-key submits.

names

Avoid name="submit"

Inputs named submit, length, or method can conflict with form properties and break APIs.

Enter

Enter-key behavior varies

Browsers differ on when Enter submits. Do not rely on a specific rule unless you handle keypress yourself.

shorthand

.submit(handler) is deprecated

Prefer .on("submit", handler). The shorthand bind form is deprecated since jQuery 3.3.

Browser Support

The submit event is a standard DOM form event. Bind with .on("submit") since jQuery 1.7; .trigger("submit") has existed since 1.0. Native submit did not bubble in old IE, but jQuery 1.4+ normalizes delegation so scripts work consistently.

✓ jQuery 1.7+

jQuery submit event

Supported in all browsers jQuery targets for forms. Prefer .on('submit') / .trigger('submit'). Use preventDefault for validation and AJAX.

100% With jQuery loaded
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
submit Excellent

Bottom line: Safe for modern and legacy jQuery projects. Bind on the form and cancel with preventDefault when needed.

Performance Notes

ApproachCostBest for
Direct .on("submit") on the formCheapValidation, AJAX gates
.serialize() in the handlerCheapBuilding POST bodies
Heavy sync work before allowExpensiveAvoid — keep checks fast

Submit handlers run once per attempt. Keep validation light so the UI feels instant; do heavy work after you decide to send.

Key Takeaways

  • Role: react when a form is about to submit — before navigation.
  • API: .on("submit", fn) and .trigger("submit").
  • Cancel: preventDefault() or return false for validation / AJAX.
  • Target: bind on the <form>, not the submit button alone.

One line: use submit on the form to validate or AJAX — cancel with preventDefault when needed.

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() tutorial →

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