Cross-field validation with Omnifaces: "Enter X and Y or enter Z"

201 Views Asked by At

When using OmniFaces, is there the possibility to validate if fields X and Y are filled out or Z?

For example "Enter firstname and lastname or enter your birthday" (firstname and lastname are two seperate fields).

What I already have:

<o:validateOneOrMore id="l3" components="firstname lastname birthday" />

Context: JSF doesn't support cross-field validation, is there a workaround?

1

There are 1 best solutions below

0
On BEST ANSWER

You can achieve the requirement by adding a <o:validateAllOrNone> referring the both name fields before the <o:validateOneOrMore>.

So, basically:

<o:validateAllOrNone components="firstname lastname" />
<o:validateOneOrMore components="firstname lastname birthday" />