Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Make Invisible Field Required When Visible, Not Required Otherwise

Avatar

Level 2

I am experimenting with the presence values and how I can better use the hidden and invisible settings. I've managed to make my invisible fields visible when needed, but I cannot determine how to conditionally control when those fields are required.

For example, I have a field that is required by default. When that field is invisible it is still required, which is a problem. Ideally I'd like to be able to set the invisible fields as required when they are visible (depending on action triggers which make them visible) but not required if they remain invisible. Does that make sense?

3 Replies

Avatar

Level 10

Hi,

To make a field optional set the validate.nullTest to "disabled" and to make it mandatory set it to "error", something like;

DateField1.validate.nullTest = "disabled"

If you are making a subform invisible then you will have to do this for each field within the subform.

Regards

Bruce

Avatar

Level 2

Thanks for the response, Bruce. I'm not sure I follow though. I know how to make a field required, but my problem is that the required validation still fires even if the field is invisible/hidden, not just when it is visible. So, my goal is to make the field required when it's visible but not required when it is invisible/hidden.

Example: I have a drop down list that is required when visible. However, the drop down field presence is conditional based on action triggers. By default the drop down is visible, but depending on certain triggers, it may become invisible. My goal is to require a value for the drop down field when it's visible only.

Avatar

Level 10

Hi,

It all depends on how your form works, but I was thinking you could put something like the DateField1.validate.nullTest = "disabled" code at the same place you had code to make your field invisible/hidden.

Bruce