Expand my Community achievements bar.

Required Fields

Avatar

Level 2

I have a form where the user answers a question, and based on their input, a subform is either hidden or visible.  In that subform, there are 4 or 5 options they can pick (checkboxes). I want them to be required to pick at least one of the 4 or 5 options, but I don't want all of the options to be required.  For example, I want them to have to pick at least A, B or C, but not all 3.  I want them to also be able to pick as many of the 4 options as they want.  I want at least one to be required though.  I'm not sure how to achieve this.  If anyone has any ideas I would be much appreciated.

I think this example illustrates this the best:

Will the room have a cabinet?  [Radio Button with choices of Yes or No] *If the user answers yes, the following question becomes visible:*

What type of cabinet will be in the room?  [There are 2 checkboxes, Type A and Type B] *I want them to have to pick either Type A or Type B, or both if they want to*

Hopefully that example helps.

Thanks in advance!

Rose.

4 Replies

Avatar

Level 10

Hi,

The example here: https://acrobat.com/#d=J0KsvCyW0s4qUECdSXMEdQ uses the specified value of the checkboxes (Binding tab) to change the mandatory aspect of the objects. If at least one of the checkboxes is ticked, then the remaining ones cease to be mandatory.

This is the script in the layout:ready event of the subform:

if (typeA.rawValue + typeB.rawValue + typeC.rawValue >= 1)

{

     typeA.mandatory = "disabled";

     typeB.mandatory = "disabled";

     typeC.mandatory = "disabled";

}

else

{

     typeA.mandatory = "error";

     typeB.mandatory = "error";

     typeC.mandatory = "error";

}

Hope that helps,

Niall

Avatar

Level 2

This seems to almost work...after I put this code in, a red border shows up now, saying that the checkboxes are required, however, it will still let me submit by email without checking one of the newly required checkboxes.

Avatar

Level 2

Is there a way to have the submit by email not work unless one of the check boxes is filled in?  The code you gave me before gave the checkboxes a red border as if it were mandatory, but it will still submit without checking one of them.

Avatar

Level 10

Below is a sample file for your reference..

https://acrobat.com/#d=0rCgvpMlczSWVFng*RDjUQ

I am using the preSubmit event of the Button with the type as "Submit" to check the mandatory field check. If nothing is entered in the mandatory field, it throws a error message and stops sending email else send an email..

Thanks

Srini