Ticket #4652 (closed bug: duplicate)
$("form").submit() doesn't work with named submit buttons
| Reported by: | ptarjan | Owned by: | brandon |
|---|---|---|---|
| Priority: | high | Milestone: | 1.4 |
| Component: | event | Version: | 1.3.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
If the <form> has a <input type="submit" name="abc" value="click me"/> then calling $("form").submit() won't trigger the form submission.
Example: http://paulisageek.com/tmp/jquery-form-bug.html
Tested on
OSX 10.5 FF3.0.10 WinXP SP3 FF3.0.10
Change History
comment:3 Changed 4 years ago by ojak
Appears to occur only when the "name" attribute of the "input" element is set to "submit".
Example:
<input type="submit" name="submit" value="Does not work" />
comment:5 Changed 4 years ago by GreatBigBore
Same problem occurs if any "input" element has an id of "submit":
<input type="button" id="submit" value="Does not work" />
Also note that it doesn't seem to matter whether the type is "submit".
comment:6 Changed 4 years ago by dmethvin
- Owner set to brandon
- Component changed from unfilled to event
This is a name ambiguity probem; see #3113. Since the workaround may be different with this one I'll leave it open.
comment:8 Changed 2 years ago by rwaldron
- Priority changed from major to high
- Status changed from open to closed
- Resolution set to duplicate
comment:10 Changed 22 months ago by mthurman
I'm new to jquery so I apologize if I'm missing anything, but I don't think this bug is a duplicate of #3685. I tried putting a fiddle together to show this: http://jsfiddle.net/aX5pw/1/
comment:11 follow-up: ↓ 14 Changed 20 months ago by anssias
I encountered this bug with jQuery 1.6.4 and Firefox 7.0.1. Just like mthurman said I don't think this ticked should closed as a duplicate.
comment:12 follow-up: ↓ 13 Changed 20 months ago by jscheel
Still experiencing this issue. When my submit button's name attr. was "submit", $.submit() did not work. Changing the name immediately fixed the issue.
comment:13 in reply to: ↑ 12 Changed 20 months ago by gnarf
Replying to jscheel:
Still experiencing this issue. When my submit button's name attr. was "submit", $.submit() did not work. Changing the name immediately fixed the issue.
This is an epic amount of information about this on http://bugs.jquery.com/ticket/1414 and https://github.com/gnarf37/jquery/commits/bug_1414.
Suffice it to say there is nothing jQuery can do to fix it.
This is an issue that is detected by DOM Lint: http://kangax.github.com/domlint/
comment:14 in reply to: ↑ 11 Changed 20 months ago by gnarf
Replying to anssias:
I encountered this bug with jQuery 1.6.4 and Firefox 7.0.1. Just like mthurman said I don't think this ticked should closed as a duplicate.
This is most definately a duplicate of #1414 which is closed "wontfix" not because we don't want to fix it, but because we have tried an amazing amount of techniques to get around this bug and none of them solve it. The "bug" is an issue with the DOM model for forms... The form.submit points at the element named submit as opposed to the function which submits the form.
comment:15 follow-up: ↓ 16 Changed 14 months ago by kobyssh
Still occurs on Chrome (18.0.1025.162 m)
comment:16 in reply to: ↑ 15 Changed 14 months ago by kobyssh
Replying to kobyssh:
Still occurs on Chrome (18.0.1025.162 m)
more details: the button's name was "submit"
comment:17 Changed 14 months ago by rwaldron
@kobyssh the solution is to not use the word "submit" as the value of an id or name. It's not jQuery, it's the DOM.
comment:18 follow-up: ↓ 19 Changed 8 months ago by romtek@…
In my case, no attribute's value is "submit", yet I experience this problem.
<input id="submitBtn" type="submit" value="Save" />
comment:19 in reply to: ↑ 18 Changed 8 months ago by romtek@…
Replying to romtek@…:
In my case, no attribute's value is "submit", yet I experience this problem.
except for type attribute, that is
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Can you change your example to include a complete head and body, and use jquery 1.3.2?