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)
Call
What it does
<form>
Only element type that receives submit
handler
function(event) — runs before default submit
eventData
Extra data available as event.data
preventDefault
Cancel navigation for validation / AJAX
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Submit the form
#out shows "Handler for submit called."
Page does not navigate
How It Works
Bind..on("submit", fn) registers the callback on the form.
Submit. Button click or Enter fires the event.
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");
});
Click #other → submit handlers run
preventDefault keeps the page here
How It Works
Bind. The submit handler is ready on #target.
Click. The outer button runs .trigger("submit").
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
});
Type "correct" → Validated...
Anything else → Not valid! (blocked)
How It Works
Submit. The form fires submit first.
Check. Read the field value in the handler.
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.