How to make a field mandatory depending on another

Hello,

On the create view of one of my documents I have a list box with 3 values: a, b, c, and a date picker.

I need the date to be set as mandatory only if a or b is present in the list box.

I've been reading here and there about JSF and found that the most approaching answer was given by this topic on stackoverflow:

http://stackoverflow.com/questions/5182106/make-a-hinputtext-required-only-when-the-checkbox-is-selected

But when I try to reproduce this kind of declaration inside my layout definition, it just doesn't work.

Can anyone please share a sample ?

0 votes

1 answers

1451 views

ANSWER




Thanks you! For any reason I had to use getSubmittedValue() instead of getLocalValue() to get it done.
04/29/2015

That's the right one to use when dealing with an input component: that's the value as submitted, before validation (when validation passes, this value is emptied and copied to the "local" value).
04/30/2015

Thanks for this usefull precision
05/22/2015

Hey Antoine Cordier,did you achieve this in client side without pressing the submit button?
11/07/2017