W3C home > Mailing lists > Public > public-html-bugzilla@w3.org > October 2012

[Bug 19751] Constraint Validation - Add a means of detecting invalid form submissions

From: <bugzilla@jessica.w3.org>
Date: Mon, 29 Oct 2012 09:46:50 +0000
To: public-html-bugzilla@w3.org
Message-ID: <bug-19751-2486-qMS3UfWHM0@http.www.w3.org/Bugs/Public/>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=19751

Mounir Lamouri <mounir@lamouri.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mounir@lamouri.fr

--- Comment #1 from Mounir Lamouri <mounir@lamouri.fr> ---
(In reply to comment #0)
> The traditional means of performing client side validation has always been
> to listen for the submit event on a form, manually perform some error
> checking logic, and prevent the form submission if necessary.
> 
> With HTML5's constraint validation this approach no longer works because a
> form will not fire a submit event until its data is deemed valid.  For most
> situations this is fine, but with the current constraint validation API it
> is not possible to know when a user attempted a form submission and it was
> prevented.

The invalid event tells you that.

> Yes an invalid event will be fired for each invalid field, but there's no
> way tell whether that event occurred because the user has just finished
> interacting with that field (i.e. blur), versus an attempted form submission.

The invalid event should only be sent when the element has been found invalid
when trying to submit the form.

> Use case: Display a list of all error messages to the user whenever they
> attempt a submission with invalid data.  This is a technique frequently used
> on web forms and it is difficult to implement with the constraint validation
> API currently.

When the 'invalid' event occurs, you can read all 'validationMessage'
attributes.

> At the moment you have to listen for anything that might trigger a
> submission (usually clicks of submit buttons) and run the appropriate logic
> there.  I give concrete code on how I've implemented this here
> http://tjvantoll.com/2012/08/05/html5-form-validation-showing-all-error-
> messages/.
> 
> While this works it is not ideal.  An event fired on the form whenever a
> form submission was attempted and failed (much like invalid on form
> elements) would make the implementation much simpler.

This is quite simple actually. See this example:
http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=1870

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
Received on Monday, 29 October 2012 09:46:51 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 29 October 2012 09:46:52 GMT