Bug Tracker

Ticket #4652 (closed bug: duplicate)

Opened 5 years ago

Last modified 21 months ago

$("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:1 Changed 5 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 5 years ago by ojak

Confirmed on Safari and FF 3.5 as well.

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

jQuery version tested: jquery-1.3.2

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

  • Status changed from new to open

comment:8 Changed 3 years ago by rwaldron

  • Priority changed from major to high
  • Status changed from open to closed
  • Resolution set to duplicate

comment:9 Changed 3 years ago by rwaldron

Duplicate of #3685.

comment:10 Changed 3 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 follow-up: ↓ 14 Changed 3 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 follow-up: ↓ 13 Changed 3 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 3 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 3 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 follow-up: ↓ 16 Changed 2 years ago by kobyssh

Still occurs on Chrome (18.0.1025.162 m)

comment:16 in reply to: ↑ 15 Changed 2 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 2 years 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 21 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 21 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

Note: See TracTickets for help on using tickets.