Bug Tracker

Opened 14 years ago

Closed 12 years ago

Last modified 11 years ago

#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:
Blocked by: Blocking:

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 (19)

comment:1 Changed 14 years ago by dmethvin

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

comment:2 Changed 14 years ago by ojak

Confirmed on Safari and FF 3.5 as well.

comment:3 Changed 14 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:4 Changed 14 years ago by ojak

jQuery version tested: jquery-1.3.2

comment:5 Changed 14 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 14 years ago by dmethvin

Component: unfilledevent
Owner: set to brandon

This is a name ambiguity probem; see #3113. Since the workaround may be different with this one I'll leave it open.

comment:7 Changed 13 years ago by dmethvin

Status: newopen

comment:8 Changed 12 years ago by Rick Waldron

Priority: majorhigh
Resolution: duplicate
Status: openclosed

comment:9 Changed 12 years ago by Rick Waldron

Duplicate of #3685.

comment:10 Changed 12 years 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 Changed 12 years 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 Changed 12 years 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 12 years 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 12 years 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 Changed 11 years ago by kobyssh

Still occurs on Chrome (18.0.1025.162 m)

comment:16 in reply to:  15 Changed 11 years 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 11 years ago by Rick Waldron

@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 Changed 11 years 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 11 years 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

Note: See TracTickets for help on using tickets.