Orbeon Disabling - Onload field validation

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Orbeon Disabling - Onload field validation

Vedha
Is there a way to disable form validation on load of the page? And only show them when user navigates through that field?
Reply | Threaded
Open this post in threaded view
|

Re: Orbeon Disabling - Onload field validation

Alessandro  Vernet
Administrator
Hi Vedha,

This is what happens by default for forms you create with Form Builder. Are you seeing something different, or maybe this isn't for a form create with Form Builder?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Orbeon Disabling - Onload field validation

Vedha
Yes, you are correct, we are writing XForms and not using Form builder. Below is the sample,

        <xf:instance id="currentFruit">
                <fruit xmlns=""> <name></name> <category>category</category> <benefits>Good for digestion</benefits></fruit>
        </xf:instance>

<xf:bind ref="instance('currentFruit')/name" constraint=". eq 'Banana'"></xf:bind>

<xf:input nodeset="instance('currentFruit')/name"><xf:alert>Error</xf:alert></xf:input>

This error shows up on load of the page. Any way to make the error show up only when user navigates on that field.
Reply | Threaded
Open this post in threaded view
|

Re: Orbeon Disabling - Onload field validation

Alessandro  Vernet
Administrator
Hi Vedha,

If you're not using Form Builder to create the form, and thus are not leveraging Form Runner, this is a tricky one, as this feature is implemented at the Form Runner level. You could of course re-implement this yourself, without using the code in Form Runner.

In essence, XForms adds the class xforms-visited to fields once the user "went through the field". So you would need to override the CSS not to show errors on the fields marked with the xforms-invalid class, unless they also have the xforms-visited class.

Then on save or submit, you'll want to show all errors, so mark all controls as visited, which you can do with with <xxf:setvisited>.

http://doc.orbeon.com/xforms/actions/extensions.html

I hope this helps,

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet