• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Creating a form with multiple checkboxes where at least one, but not all, is required to be checked?

New Here ,
Jun 27, 2024 Jun 27, 2024

Copy link to clipboard

Copied

I've been googling around trying to figure this out on my own, but everything I find is triggered by a submit or email button.  This form is to be filled out by the applicant and then emailed into their local office so neither of those buttons will do it.

 

For the most part I've set all fields and radio buttons to required and then set up a warning popup when they try and save or print.  But one section of my form asks what the months of use will be, and they can choose "year round", or any number of specific months.  Setting them to "required" will of course trigger the script for each box that isn't filled out, but setting them as not required would risk them missing that section, which would delay the process.  As far as I can tell from looking it up, there is no option to allow selection of multiple radio buttons.  Is there anything I can do to make this work?

TOPICS
How to , JavaScript , PDF , PDF forms

Views

389

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 27, 2024 Jun 27, 2024

Since the form is emailed by the user, there is no simple way to do a whole form validation. But there are two simple solutions.  

1) Provide a form validation button that the user can press voluntarily to verify that all required elements are entered. 

2) Show the validation status somewhere on the form in such a way that it can't be ignored. For example, in the header and footer.  Then you'd also need to highlight the problem fields somehow. And easy solution for this is to change the border o

...

Votes

Translate

Translate
Community Expert ,
Jun 27, 2024 Jun 27, 2024

Copy link to clipboard

Copied

LATEST

Since the form is emailed by the user, there is no simple way to do a whole form validation. But there are two simple solutions.  

1) Provide a form validation button that the user can press voluntarily to verify that all required elements are entered. 

2) Show the validation status somewhere on the form in such a way that it can't be ignored. For example, in the header and footer.  Then you'd also need to highlight the problem fields somehow. And easy solution for this is to change the border or backgroud of fields to red. 

 

These technique require a script, and so will only work with the desktop Acrobat Pro or Reader. 

There is no solution for forms that are filled out on a mobile device. 

 

Now, here is a method to verify that one or more checkboxes is filled in. 

1) Give all the checkboxes that need to be checked together a group name, such as "Section1.Check1", "Section1.Check2",  etc. 

2) the group naming allows all of the check boxes to be accessed at once. Here is a function that returns true if at least one checkbox in the group is checked. It should be placed in a document script. 

 

function ValidateCheckBoxGroup()

{

      return this.getField("Section1").getArray().some(a=>a.value != "Off");

}

This function should be called each time you want to validate the checkbox selection. It could be done in the mouse up/down event for each checkbox, or in a calculation script. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines