The submit event fires when the user attempts to send a <form> — click a submit button, press Enter, or call .trigger("submit"). This tutorial covers .on("submit"), eventData, event.preventDefault(), validation before send, AJAX patterns, and the official jQuery API demos.
01
.on()
Bind handler
02
prevent
Default
03
.trigger()
Fire submit
04
<form>
Only forms
05
Validate
Before send
06
Since 1.7
Modern API
Fundamentals
Introduction
Login forms, contact forms, and checkout pages all need one critical hook: code that runs right before the browser sends data to the server. The submit event is that hook — it fires when the user tries to submit the form, giving you a chance to validate, show errors, or send data with AJAX instead of a full page reload.
The official jQuery API distinguishes the submitevent (bound with .on("submit") since 1.7) from the deprecated .submit()method in older code. To programmatically run submit handlers, use .trigger("submit") since jQuery 1.0.
Concept
Understanding the submit Event
The submit event is sent to a <form> element when the user is attempting to submit it. It can only be attached to forms — not individual inputs, buttons, or divs.
Forms submit when the user clicks an explicit <button type="submit">, <input type="submit">, or <input type="image">, or when Enter is pressed under certain browser conditions. Your handler runs before the actual submission — so you can cancel it with event.preventDefault() or return false.
💡
Beginner Tip
Always call event.preventDefault() when you handle submit with AJAX. Without it, the browser still performs the default action — navigating to the form’s action URL — even after your $.ajax() call starts.
Foundation
📝 Syntax
The modern jQuery API for the submit event has two main forms — binding a handler and triggering the event:
$( "#app" ).on( "submit", "form", function( event ) {
// runs when any form inside #app is submitted — including future ones
} );
jQuery normalized submit delegation across browsers since 1.4 (native submit did not bubble in IE). You can bind on a parent container for multiple forms, though binding directly on the <form> is most common.
3. Trigger the event — .trigger("submit") (since 1.0)
jQuery
.trigger( "submit" )
Runs bound submit handlers on the matched element(s).
Also fires the browser default submit action unless you call preventDefault() or return false.
📋 submit vs click vs change vs deprecated .submit()
Four related form concepts — know which fires on the form, the button, or individual fields.
submit event
form send
Form is being submitted — validate, preventDefault, or AJAX replace
click event
button
Mouse press on submit button only — misses Enter-key submits
change event
value diff
Single field value changed — not the same as submitting the whole form
.submit() method
deprecated
Old binding shorthand — use .on("submit") and .trigger("submit") instead
Hands-On
Examples Gallery
Examples 1–2 follow the official jQuery API documentation. Examples 3–5 extend the official validation demo, flag-variable pattern, and AJAX submit. Use the Try-it links to run each snippet in the browser.
📚 Binding & Triggering
Official jQuery demos for submit handlers and programmatic triggers.
Example 1 — Official Demo: Bind Handler on #target
Alert when the form is submitted — cancel the default action with event.preventDefault().
Click #other → trigger("submit") → alert runs
Same handler as clicking the form Submit button
Without preventDefault, form would also post to action URL
How It Works
.trigger("submit") synthetically fires the event. Handlers run and, unless prevented, the browser performs the default submit — navigating to action.
📈 Validation & AJAX
Official extended demos for validation, conditional submit, and AJAX patterns.
Example 3 — Official Demo: Type “correct” to Validate
Block submission unless the first input equals correct — show feedback with preventDefault().
Type "wrong" + Submit → "Not valid!" fades out, form blocked
Type "correct" + Submit → "Validated..." shown, form submits
Official jQuery API validation pattern
How It Works
When validation passes, the handler returns without preventDefault() — the form submits normally. When it fails, preventDefault() cancels the submission and shows an error message.
Example 4 — Official Demo: Conditional Submit with Flag Variable
Return a boolean from the handler — return false cancels submit the same as preventDefault().
Submit while allowSubmit is false → form blocked (return false)
Click Enable → allowSubmit = true
Submit again → form proceeds (handler returns true)
How It Works
Returning false from a jQuery event handler is equivalent to calling both preventDefault() and stopPropagation(). Returning nothing or a truthy value allows the default submit to continue.
Example 5 — AJAX Submit with serialize()
Prevent default navigation and post form data with $.ajax() — common SPA pattern.
User clicks Send → preventDefault stops page reload
$.ajax posts serialized field values
#result updates with server response (demo uses mock endpoint)
How It Works
.serialize() converts form fields to a query string. preventDefault() is mandatory — without it, the browser navigates away while AJAX is in flight.
Applications
🚀 Common Use Cases
Client-side validation — block invalid forms with event.preventDefault() before data reaches the server.
AJAX login and contact forms — preventDefault + $.ajax + .serialize() for no-reload submits.
Multi-step wizards — intercept submit on intermediate steps, validate, then advance without posting.
Confirm dialogs — if (!confirm("Send?")) event.preventDefault() before destructive actions.
Analytics tracking — log form submission attempts in the handler before allowing default submit.
Custom submit buttons — $("#myForm").trigger("submit") from a styled div outside the form.
🚀 How the submit Event Flows
1
User submits
Clicks submit button, presses Enter, or code calls .trigger("submit").
attempt
2
submit event fires
Handler runs on the <form>before the browser sends the request.
submit
3
Handler decides
Validate, AJAX, or preventDefault() to cancel. return false also cancels.
prevent?
4
🚀
Default or blocked
If not prevented, browser posts to action URL. If prevented, page stays — your AJAX or error UI runs instead.
Important
📝 Notes
Bind with .on("submit", handler) since jQuery 1.7 — not the deprecated .submit(handler) method.
Trigger with .trigger("submit") since jQuery 1.0.
Limited to <form> elements — not individual inputs or buttons.
Handler runs before navigation — use event.preventDefault() to cancel.
return false from handler = preventDefault() + stopPropagation().
Avoid naming inputs submit, length, or method — conflicts with form properties (DOMLint).
jQuery normalized submit delegation since 1.4 for cross-browser consistency.
Use .off("submit") to remove handlers — avoid deprecated .unbind("submit").
Compatibility
Browser Support
The submit event is a standard DOM form event supported in every browser jQuery targets. jQuery’s .on("submit") (since 1.7) and .trigger("submit") (since 1.0) normalize cross-browser behavior — including submit delegation fixed in jQuery 1.4.
✓ jQuery 1.7+
jQuery submit event
Supported in jQuery 1.x, 2.x, and 3.x across all modern browsers and IE with supported jQuery versions. Native equivalent: form.addEventListener('submit', fn) — jQuery adds collection binding, eventData, delegation, and .trigger() in one chainable API.
100%With jQuery loaded
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
submitUniversal
Bottom line: Safe in any jQuery project. Prefer .on('submit') over deprecated .submit() for binding. Always preventDefault for AJAX submits.
Wrap Up
Conclusion
The jQuery submit event is the standard hook for form validation and AJAX submission. Bind handlers with .on("submit", fn), pass optional eventData, and fire handlers programmatically with .trigger("submit"). Cancel unwanted submissions with event.preventDefault() or return false.
Remember: submit fires on the <form>, not individual fields. Use change or blur for per-field validation, then a final submit handler for whole-form checks. For dynamic multi-form pages, delegate with $("#app").on("submit", "form", fn).
Bind with .on("submit", handler) on the form element
Call event.preventDefault() for AJAX and failed validation
Use .serialize() or FormData to collect field values
Validate on submit for whole-form rules; use blur for field-level hints
Delegate on #app when multiple dynamic forms share one handler
❌ Don’t
Use deprecated .submit(handler) for new code — use .on("submit")
Bind submit on individual inputs — it only works on <form>
Forget preventDefault in AJAX handlers — page will still navigate
Confuse submit with click on the button — submit covers Enter key too
Name form fields submit or method — breaks form properties
Summary
Key Takeaways
Knowledge Unlocked
Six things to remember about the submit event
Validate, prevent, send.
6
Core concepts
.on01
.on("submit")
Bind
API
stop02
preventDefault
Cancel
Block
⚡03
.trigger()
Fire
Programmatic
form04
<form>
Only forms
Scope
ajax05
AJAX
No reload
Pattern
↑06
Before send
Timing
Hook
❓ 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 handlers with .on('submit', handler) since jQuery 1.7. The handler runs before the browser navigates away or sends the request.
Call event.preventDefault() inside your submit handler, or return false from the handler. Both cancel the default form submission so the page does not reload. This is essential for client-side validation and AJAX submits: if validation fails, preventDefault stops the bad data from being sent.
click fires when the user presses and releases the mouse on the button. submit fires on the form when a submission is attempted — including Enter key presses that the browser treats as submit. Bind submit on the form for validation that covers every submission path; bind click only when you need button-specific behavior.
Browser behavior varies. Enter may submit when the form has one text field, when a submit button is present, or under other rules depending on the browser. Do not rely on a specific Enter-key behavior unless you observe keypress yourself. The submit handler still runs whenever the browser decides to submit.
Call $('#myForm').trigger('submit') since jQuery 1.0. Bound submit handlers run, and unless you preventDefault, the browser also performs the default submit action — navigating or posting the form. Use this to submit from a custom button outside the form or to re-run validation logic.
Native submit did not bubble in Internet Explorer, but jQuery normalized delegation since 1.4 so .on('submit', handler) on forms works consistently across browsers. You can also delegate from a parent container, though binding directly on the form is the most common pattern.
Did you know?
Returning false from a jQuery submit handler cancels the submission — jQuery treats it like calling event.preventDefault() and event.stopPropagation() together. That is why the official API demo can use return this.some_flag_variable to conditionally allow or block submit. Prefer explicit event.preventDefault() in new code for clarity.