Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

disable mandatory fields when subform is hidden

Avatar

Former Community Member

I am having a problem with a new section of a form I've created. When a box is checked a section pops up. Then within that new section, there are more options to choose.  The problem is, when the form is hidden the mandatory fields are still being recognized as mandatory.  (atleast I think that's what is wrong). Im hoping someone can offer some help. I will likely have to send you the form, as its easier to explain when you see the form. If anyone can Help i would greatly appreciate it.


Thank you,


Nik

1 Accepted Solution

Avatar

Correct answer by
Level 10

Instead of making the field as mandatory in the object palette properties, check whether the field is null or has value using script before the form is submitted..

That way you can have more control on the mandatory check. You can only check if the subform is visible.

Here is a sample with what I am talking about..

https://acrobat.com/#d=QUAfLtK2Pr9oHv9Q59rT4Q

Thanks

Srini

View solution in original post

7 Replies

Avatar

Correct answer by
Level 10

Instead of making the field as mandatory in the object palette properties, check whether the field is null or has value using script before the form is submitted..

That way you can have more control on the mandatory check. You can only check if the subform is visible.

Here is a sample with what I am talking about..

https://acrobat.com/#d=QUAfLtK2Pr9oHv9Q59rT4Q

Thanks

Srini

Avatar

Level 10

Hi,

On the event that sets the subform presence to hidden/invisible, you could include a script to set the mandatory to disabled:

textField1.mandatory = "disabled"; 

Then the script that changes the presence to visible, include a script to reset the field to required:
textField1.mandatory = "error"; 
Hope that helps,
Niall

Avatar

Former Community Member

Hi Niall,

I have done that however for some reason it is still not working correctly. I have used that on other sections of my form and it does work, so i'm wondering if it has to do with the fact that within the hidden form i also have a check box that, if checked, fields (some mandatory) disappear.

Avatar

Level 10

Hi,

Here is a sample: https://acrobat.com/#d=dQgzjM1hQAz6dX3vtlS87w

Main thing is to set the mandatory property of the objects BEFORE you hide the subform.

Good luck,

Niall

Avatar

Former Community Member

Hi Niall,

I have been using what you showed me in your first response and it has worked fine up until now.  Any other suggestions?

Avatar

Level 10

Hi,

Not sure I follow the problem. Can you upload the form to a file sharing site?

The sample I uploaded works by making the fields not required before the subform is hidden. Is that any help to you?

Niall