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

https://www.w3.org/Bugs/Public/show_bug.cgi?id=19751

--- Comment #6 from Robin Berjon <robin@w3.org> ---
(In reply to comment #2)
> (In reply to comment #1)
> > > 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
> 
> The issue with this approach is that the logic will run once per invalid
> field on the form.  If you give an invalid email address in your example
> you'll end up with two alerts.  Unless I'm missing something there's no way
> to run the logic just one time per attempted submission with the current API.

The OP has a point here Mounir, alerting twice doesn't help. I hit the same
issue with a more sophisticated example in which my invalid handler would cause
an error dialog element to be shown, and would append the validationMessage to
an ul. This all sounded great, until the user submitted again with errors, at
which point it just appended errors to the list without clearing the previous
ones (since nothing said that all errors had been received). There are
work-arounds, but we shouldn't design something on such grounds.

TJ: is there a preferred solution you would have here? Perhaps a new
invalid-submit event with all validationMessage collected and mapped to the
relevant elements?

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Monday, 11 March 2013 15:52:10 UTC