Modify ↓
Ticket #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: | ||
| Blocking: | Blocked by: |
Description
When a form is submitted via document.formName.submit(), it is not caught by the .submit() function bound to the form.
Example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<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() {
alert('Submitted!');
return false;
});
});
</script>
</head>
<body>
<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();" />
</form>
</body>
</html>
The 'Submit' button is properly caught (and an alert displays), but 'Submit with document.testForm.submit()' is not.
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

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