reportValidity() permanently changes state of form (even if reset)

RESOLVED FIXED in Firefox 59



2 years ago
5 months ago


(Reporter: sliploj, Assigned: jdai)


57 Branch

Firefox Tracking Flags

(firefox59 fixed)



(2 attachments)

When reportValidity() is called on a form, any invalid fields get highlighted, as expected. However, if the form is later reset, whether by calling reset() or by clicking on an input of type "reset", any inputs that e.g. are marked required but are blank after reset will be marked as invalid (in most cases the entire form would be marked invalid since reset typically makes a form mostly/blank). The earlier call the reportValidity permanently changed the state of the form such that even resetting it doesn't clear validation status (even though I don't see anything in the spec about reportValidity being a call that should result in a permanent state change, but instead seems to be described as a one-off event). As far as I can tell, there's no way to clear the validation status of a form after calling reportValidity.

This is in contrast to what happens if reportValidity() has not previously been called. If reportValidity() hasn't been called, but a field is marked invalid, resetting the form also clears the validation status for the fields (i.e. e.g. required fields that are blank as result of reset won't be marked invalid (until the user interacts with them again)).

I've found that the lack of a way to clear the validation status of a form after calling reportValidity() is problematic e.g. if a form is supposed to get reused, because on re-use it already shows up with blank fields marked as invalid.
Reporter, could you kindly attach a minimal testcase showing the issue to this bug?
Flags: needinfo?(sliploj)
attaching HTML file with inline instructions for demonstrating the issue
Flags: needinfo?(sliploj)
for whatever it's worth, Edge and Internet Explorer don't have this problem; the issue doesn't apply in Chrome either since it doesn't use a border to highlight the fields
John, since you've been working on reportValidity (bug 1088761), could you take a look?
Flags: needinfo?(jdai)
Sure, I'll take a look. Keep NI for tracking.
Priority: -- → P2
I am able to reproduce this issue by using the testcase (attachment 8939383 [details]).
Assignee: nobody → jdai
Ever confirmed: true
Attachment #8940998 - Flags: review?(bugs) → review+
Keywords: checkin-needed
Pushed by
Fix reset a form can't clear -moz-ui-invalid after calling reportValidity. r=smaug
Keywords: checkin-needed
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.