Bug Tracker

Opened 15 years ago

Closed 15 years ago

Last modified 10 years ago

#3115 closed bug (wontfix)

document.formName.submit() is not caught by .submit() binding

Reported by: jstayton Owned by:
Priority: minor Milestone: 1.3
Component: event Version: 1.2.6
Keywords: Cc:
Blocked by: Blocking:


When a form is submitted via document.formName.submit(), it is not caught by the .submit() function bound to the form.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      <title>jQuery .submit() example</title>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <script type="text/javascript" src="jquery-1.2.6.min.js"></script>
      <script type="text/javascript">
         $(document).ready(function() {
            $('form[name="testForm"]').submit(function() {

              return false;
      <form name="testForm" action="submitExample.html" method="post">
        <input type="text" name="textField" value="Press submit" />
        <input type="submit" name="submitButton" value="Submit" />
        <input type="button" name="submitButton" value="Submit with document.testForm.submit()" onclick="document.testForm.submit();" />

The 'Submit' button is properly caught (and an alert displays), but 'Submit with document.testForm.submit()' is not.

Change History (2)

comment:1 Changed 15 years ago by flesler

Component: coreevent
Resolution: wontfix
Status: newclosed

I think this is how it works natively. Calling form.submit() will simply skip the handlers.

Use $(form).submit() instead.

comment:2 Changed 10 years ago by dmethvin

#12575 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.