Page MenuHomePhabricator

Suppress native "invalid e-mail" warning on Special:ChangeEmail (since we do our own validation)
Closed, ResolvedPublic

Description

browser tooltip and MediaWiki div both warning invalid email

With $wgHtml5 now true on en-wiki, the form field attribute type=email in MediaWiki forms flows to the browser. This makes recent browsers validate e-mail addresses on submit. Which is fine, except when the form does its own client-side validation, in which case two validation messages appear simultaneously. See screenshot.

To reproduce, visit Special:ChangeEmail, enter a bad e-mail, tab out of the field, and click [Submit] or press the [Enter] key.

This may also happen with other forms using HTMl5 input types that trigger browser validation that do their own client-side validation.

A workaround is to disable the browser's validation with attributes novalidate and formnovalidate; it would be better to somehow cooperate with the browser's implementation.


Version: 1.21.x
Severity: minor
Whiteboard: gci2013
URL: https://en.wikipedia.org/wiki/Special:ChangeEmail
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=56363

Attached:

Details

Reference
bz40909

Event Timeline

bzimport raised the priority of this task from to Low.
bzimport set Reference to bz40909.

You can bind a listener to the browser's native 'invalid' event. When you hear it you can output your own invalidity UI and then cancel the event. Canceling the event will not disable the validation (the form will still not submit) but it will disable the browser's native UI.

richardg_uk wrote:

Bug 40585 is also caused by HTML5 form validation (input type="number" with step="any" stripped by Html::expandAttributes() prevents client submission of non-integer numbers).

Change 96195 had a related patch set uploaded by Theopolisme:
Supress native "invalid email" warning on Special:ChangeEmail

https://gerrit.wikimedia.org/r/96195

Change 96195 merged by jenkins-bot:
Supress native "invalid email" warning on Special:ChangeEmail

https://gerrit.wikimedia.org/r/96195

Fixed by Theo as part of his GCI work. Thanks!