2

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?

Community
  • 1
  • 1
Thomas Schmidt
  • 1,248
  • 2
  • 12
  • 37

1 Answers1

2

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" />
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555