Expand my Community achievements bar.

SOLVED

Make certain fields Required in a repeating subform - checked/validated on preSubmit

Avatar

Level 6

I have a form that contains a repeating subform - meaning, there is a single subform (flowed Western) with Binding set to repeat a Min of 1, and Max of 15 (hence dynamic repeating subform).

Within the subform are 5 fields (example fields below):

First Name

Last Name

Email Address

Age

Gender (Radio button for male/female)

If the user enters a value for First Name, then the Last Name, Age, and the Gender radio button should all become "required". Similarly, if first First Name value is empty/null, then the Last Name, Age, and Gender radio button fields should be optional.

I understand this can be achieved quite easily if the subform wasn’t repeating:

if (!(this.isNull)) { //if First Name field isn't null

          LastName.mandatory = "error";

          Age.mandatory = "error";

          //etc

}

else { //if field is null

         LastName.mandatory = "disabled";

          Age.mandatory = "disabled";

          //etc

}

However, how is this achieved in a repeating subform?  If the above script is placed in the repeating subform, it affects ALL repeating rows in the subform group once rendered. Instead, I need it the conditional mandatory status to treated on a unique instance basis (row-by-row).

Thanks in advance

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

I don't see a problem to make this even working with repeated subforms.

Here's a sample for you.

https://files.acrobat.com/preview/7dc1e4aa-5160-4058-a59e-77b77dbf658f

Hope this helps.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

I don't see a problem to make this even working with repeated subforms.

Here's a sample for you.

https://files.acrobat.com/preview/7dc1e4aa-5160-4058-a59e-77b77dbf658f

Hope this helps.

Avatar

Level 6

Thanks Radzmar.

I knew this was such a simple thing to do.. I'm not sure why ALL of the fields on each row were being affected the last time we tried to use the script. For example, if the user entered a value for First Name, then the Last Name, Age, and the Gender fields become "required" on ALL rendered rows - not just that affected row. Now, it's only affecting the a single row, as desired.

Thanks - I love the fact that you all are so helpful in this forum!

Shawn