Search code examples
jqueryvalidationorbeon

Disable Orbeon "as you type" validation for empty (never filled) fields?


As Orbeon forms normally operate, when a user changes from one field to another, the validation of the first field gets triggered, which is totally ok in general.

I'm facing a requirement that as-you-type validation (required fields) should not be performed for those fields which were and remained empty, i.e. if a user loads the form and only clicks in and out of the field, or moves over it by Tab.

So in case those fields remain empty, they will be validated at the end, when the user submits the entire form.

Is there a possibility to limit Orbeon as-you-type validation like that, not do it for empty fields?


Solution

  • Right now, you can't switch to the behavior you're describing, say, by setting a property. But I see how it could make sense, in some cases. As you said, the idea is that you wouldn't show errors for a field if the user never typed anything in it. For instance, with a required field:

    1. The user tabs in, doesn't type anything, and tabs out ⇒ no error shown (while right now, an error would be shown).
    2. The user sets the focus back in the field, types something, tabs out ⇒ no error is shown (obviously, since a value was provided).
    3. The user deletes the value in the field, tabs out ⇒ error shows (this even if the field is empty now, because the user had entered a value). And in all cases, all errors show on save/submit, as they do now.

    Implementing this, could be done by changing, in the XForms engine, the notion of "visited" to match the above description. The error summary would be updated accordingly, as it uses xxf:visited() to decide which errors to show.