jquery-form / jquery-form/form

<button> elements with no "type" don't send their value on submit

Open
#588 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.1k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

Please review Instructions for Reporting a Bug.

Description:

elements with no type attribute default to type "submit" (see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type).

When clicked, the form should be submitted and the request should contain the value of the button.

Expected Behavior:

With this form:

<form>
<button name="button1" value="ok">Button without type</button>
<button name="button2" value="ok" type="submit">Button with type</button>
</form>

Clicking either button should send the values "button1=ok" or "button2=ok".

Actual behavior:

Without ajaxform, the form works as expected in Firefox and Chromium.

With ajaxform, clicking button2 works as expected, but clicking button1 doesn't send "button1=ok".

Remarks

This is caused, as far as I understand, by the captureSubmittingElement function looking explicitly for elements with "type=submit".

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the captureSubmittingElement function mentioned in the report and reproduce the behavior with the provided HTML form. Verify that clicking either button submits its name and value, including the button without an explicit type attribute.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.