Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Running scripts based on the presence of parents subform

Avatar

Former Community Member
I've been developing a dynamic form wjich i've been working on for 7 weeks.

I've build mandatory and validation checks for the entire form. Its a for which kan collapse based on user actions.



As output this form gan generate more than 25 different versions.



Now my problem:



I'd like to run javascripts (mandatory checks) before the form is being saved by the user. Some fields and their subforms are not visible because the user which is filling out the form made choices which don't require those fields/sections of the form to be filled.



I scripted a function which checks all fields where i placed mandatory check.

But i want the function to only check the fields for mandatory if the parent subform is visible. Is this possible?

Now the user gets errors because not all required fields were filled out. But they actually are filled OK only the hidden sections have some mandatory fields which are not visible and therefore are not filled either.



Thx in advance!
3 Replies

Avatar

Former Community Member
hi rob, if i understood your problem, this could be the solution:



somewhere you have your javascriptt(mandatory checks). you could go through the subforms and check whether they are visible or hidden:



if(mySubform[i].presence==visible){



(mandatory checks);



}



hope this will help.

Avatar

Former Community Member
thought it was that easy too, but no luck till now



IF "condition" is True

then run the mandatory checks

ELSE

do nothing



Looks pretty simple and logical



But it does not work :( Somebody?

Avatar

Former Community Member
hi rob,



what is precisely not working? you may have defined 'wrong' paths to the subform. Or what does exactly happen?



let me know.