Remove 'x-moz-errormessage' attribute

RESOLVED FIXED in Firefox 66

Status

()

enhancement
P2
normal
RESOLVED FIXED
5 months ago
2 months ago

People

(Reporter: baku, Assigned: baku)

Tracking

({dev-doc-complete, site-compat})

Trunk
mozilla66
Points:
---

Firefox Tracking Flags

(firefox66 fixed)

Details

Attachments

(1 attachment)

Assignee

Description

5 months ago
x-moz-errormessage attribute can be used to have a custom error message when validating a form field. This is a mozilla-only attribute which was rejected in 2010 by w3: https://www.w3.org/Bugs/Public/show_bug.cgi?id=10923

Currently, a similar message can be set using setCustomValidity() method: https://html.spec.whatwg.org/#dom-cva-setcustomvalidity

This bug is about removing the support for this attribute.
There are web pages hinting about this attribute, some pages say that title attribute would work the same way in some browsers. Better to verify how title attribute works elsewhere.
Hmm… I could have used this recently for Web Payments UI if I had known about it.

(In reply to Olli Pettay [:smaug] (high review load) from comment #1)
> There are web pages hinting about this attribute, some pages say that title
> attribute would work the same way in some browsers. Better to verify how
> title attribute works elsewhere.

It sounds like Blink used to use @title to override the custom message but stopped doing so years ago.

We currently only use @title with @pattern and a problem is that we append our own string[1] to the @title but that's often not ideal. For example, UX wanted us to show the message "Enter a valid ZIP code for the country or region" but if we did:
> <input pattern="[0-9]{5}" title="Enter a valid ZIP code for the country or region">
leads to
> Please match the requested format: Enter a valid ZIP code for the country or region
which isn't great.

In our case we were already using `setCustomValidity` for another class of errors and it would have been a lot of work to re-implement @pattern and the other constraint attributes with `setCustomValidity` just to handle changing the message to remove the "Please match the requested format: " prefix.

For complicated forms it seems like a way to override the message shown while invalid without actually marking the field as invalid, like x-moz-errormessage, is still useful.

[1] https://dxr.mozilla.org/mozilla-central/rev/c2593a3058afdfeaac5c990e18794ee8257afe99/dom/locales/en-US/chrome/dom/dom.properties#45-46
Assignee

Comment 3

5 months ago
Attachment #9031373 - Flags: review?(bugs)
Attachment #9031373 - Flags: review?(bugs) → review?(echen)

Updated

5 months ago
Priority: -- → P2
Comment on attachment 9031373 [details] [diff] [review]
validation.patch

Review of attachment 9031373 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good to me.
Attachment #9031373 - Flags: review?(echen) → review+

Comment 5

5 months ago
Pushed by amarchesini@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/6533f8297b30
Get rid of x-moz-errormessage attribute, r=edgar

Comment 6

5 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/6533f8297b30
Status: NEW → RESOLVED
Last Resolved: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla66

I've documented this:

mentioned that the attribute is removed in 66, and added an example of what you should do instead, to
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Custom_error_messages

Removed any mention of the attribute from
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation

Added compat data:
https://github.com/mdn/browser-compat-data/pull/3364

Added a note to the Fx66 rel notes:
https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/66#HTML

Let me know if that's OK, thanks!

Component: DOM → DOM: Core & HTML
Product: Core → Core
You need to log in before you can comment on or make changes to this bug.