Highlight validation-error on required field

All,

I have two use-cases for form submission error handling/highlighting that I
am not sure how to manage with vanilla XForms.

*validation-error scenario 1*

I recently posted this help request to the XSLTForms sourceforge page
regarding highlighting a required field upon form submission:
https://sourceforge.net/projects/xsltforms/forums/forum/878085/topic/6025530

In essence I am trying to emulate a common HTML form behaviour by
highlighting fields where incorrect values have been provided or where a
mandatory field has been left blank. When the field is invalid I can
achieve this via the xforms-invalid event which then associates the :invalid
css psuedo class (or .xforms-invalid in the case of XSLTForms) with the
appropriate form elements. When a required field is left blank however no
css class is associated with the element and although the form submission
fails I cannot help the user easily identify which form element was the
cause.

With pure HTML forms it is fairly typical to highlight required fields that
are empty after the user presses the submit button: this is the behaviour I
am trying to recreate. Perhaps the addition of a new CSS class upon form
submission would allow some control? Is this something that would be
required in the XForms language, or would this be implementation specific?

To test out the behaviour try submitting the form at
http://www.forms4health.com/registration.xml

a) Try putting in an invalid email address (e.g. fred) and press the book
button - a global validation error is shown and the offending field is
highlighted
b) If you leave the field blank and press the "book" button - a global
validation error is shown, but I currently cannot highlight the offending
field

*validation-error scenario 2*

As an additional requirement (and this is probably less common), I want the
user to provide at least one value for a form entry in an <xf:repeat/>
section. At the moment the backend picks up this fault and sends an error
message back, however it would be good if the form on the client side could
do the same and (as above) highlight the offending field to the user.

To try this out use the same form (
http://www.forms4health.com/registration.xml), put in a valid email address
and leave the "booking reference" blank. Again a global validation error is
provided but the offending field is not highlighted.

Any thoughts?

Michael

Received on Thursday, 1 November 2012 17:33:55 UTC