Skip to main content
somebunny
Known Participant
August 14, 2016
Answered

Acrobat XI Pro Form: at least one of six checkboxes is required to be checked

  • August 14, 2016
  • 1 reply
  • 2485 views

Hi,

I am creating a form using Adobe Acrobat XI Pro.

On one part of the form, there are 6 different checkboxes in a row, of which, at least one is required to be checked.

Is there some javascript that I can use, so that when a user goes to the textfield after the checkboxes, that it will not let them go further, until they go back and check one of the boxes?

Or, if I can't have that ...  some javascript code that will not let them "submit" the form if one of the checkboxes is not checked?

I would appreciate any help.

Thank you.

This topic has been closed for replies.
Correct answer try67

The former is problematic and I would not pursue it.

The latter is possible, but requires using a custom-made script. One easy way of doing it is creating a required (hidden) text field with the default value "Off" and use a script to copy the values of the check-boxes into it. That way, if no value is entered, the validation of that field will fail.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 14, 2016

The former is problematic and I would not pursue it.

The latter is possible, but requires using a custom-made script. One easy way of doing it is creating a required (hidden) text field with the default value "Off" and use a script to copy the values of the check-boxes into it. That way, if no value is entered, the validation of that field will fail.

somebunny
somebunnyAuthor
Known Participant
August 14, 2016

Hi Try67,

Thank you very much for your advice.

By any chance, would you be able to give me the javascript code that would do what you suggest?

Also, I am not sure how to make the default value = "Off" on a text field.  I looked, but I do not see that option.

I would really appreciate it, if you could give me the javascript code, and tell me if I would apply the javascript code via the "Actions" tab, using the "Run a javascript" action, or if I would apply it via the "Calculate" tab using the "Custom Calculation Script" area.

Your help is very much appreciated.

Thank you.    : )

somebunny
somebunnyAuthor
Known Participant
August 15, 2016

omg ...   hi Try67,

I found some old code of your's online and I tried it....

I made a required, hidden text field.  I placed it at the end of the row of checkboxes.  Then, I put your code into the Custom Calculation Script area under the Calculate tab.

This is the code I used:

var checkboxes = ["CkRTPY","CkRTBen", "CkRTWFA", "CkRTGL", "CkRTRpt",  "CkRTUnk"];

var v = "";

for (var i in checkboxes) {

     if (v=="" && this.getField(checkboxes).value!="Off")

          v = "OK";

}

  1. event.value = v;

... and it worked!!!    Upon Submit it will not let me submit because it says that something required is not filled in.  I had all of my other required fields filled in already...  That's how I know it is the checkboxes...

Only one slight problem now ...  The checkboxes do not get highlighted in red, like all of the required text fields do, when you try to submit them, when they are not filled in.

Is there any way we can make it so it highlights the checkbox area, when at least one of them is not checked?

Thank you ahead of time for your help.  I'm getting very excited...  I really hope there is some way to show that it is the checkboxes that are the missing required item.

Thank you!