Closed Bug 982039 Opened 11 years ago Closed 10 years ago

Radio input required not working when element disabled by js

Categories

(Core :: DOM: Core & HTML, defect)

28 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: markus.doits, Assigned: smaug)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:28.0) Gecko/20100101 Firefox/28.0 (Beta/Release) Build ID: 20140306171728 Steps to reproduce: When a required radio input disabled by js after the page loaded, the required check is not working and submitting the form even nothing is checked. See http://jsfiddle.net/3Xa4g/13/ - simply click on submit and the form is submitted even the radio input is not checked. Actual results: The form is submitted even no radio input is checked. Expected results: The form should be marked as invalid and not submitted until a radio button is checked.
Confirmed on Firefox 28 and on Nightly as well. Works as I'd expect it to in Chrome, but not in Safari. I'm not sure if this is an issue for HTML Form submission, or something else.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Component: Untriaged → HTML: Form Submission
Product: Firefox → Core
This is a bit exciting. HTMLInputElement::UpdateValueMissingValidityStateForRadio has this bit: valueMissing = IsMutable() && required && !selected; Of course in this case, IsMutable() is false. And then it does: container->SetValueMissingState(name, valueMissing); What we should probably do instead is just treat disabled+required radios as not required in HTMLFormElement::RadioRequiredChanged, invoke that when @disabled changes, and then drop the IsMutable() bits in UpdateValueMissingValidityStateForRadio, since those will no longer be necessary. Olli, would that make sense?
Flags: needinfo?(bugs)
Attached patch patchSplinter Review
Assignee: nobody → bugs
Attachment #8453361 - Flags: review?(bzbarsky)
Flags: needinfo?(bugs)
Comment on attachment 8453361 [details] [diff] [review] patch Hmm. I _think_ this works...
Attachment #8453361 - Flags: review?(bzbarsky) → review+
Bah, ###!!! ASSERTION: mRequiredRadioCount about to wrap below 0!: 'radioGroup->mRequiredRadioCount != 0'
Oh, wait, that is an existing bug.
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
Component: HTML: Form Submission → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: