Limit PDF Checkbox Selections by Radio Button in Adobe Acrobat
Question details
Limit the number of options selected in a PDF booking form according to the package chosen with a radio button.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- An event booking form has approximately 15 options and two packages that allow up to five or seven checkbox selections.
- Observed behavior
- The form should prevent additional selections when the chosen package limit is reached and allow new selections when an option is cleared.
Open the form in Adobe Acrobat Pro and check that its fields are editable in Prepare a Form. Confirm the checkbox field names and radio button export values before adding JavaScript.
Use Acrobat JavaScript to enforce each package limit
Use this method to disable unchecked options at the limit and automatically clear excess selections if a user switches to a smaller package.
This example enforces a maximum, not an exact number of selections. It keeps options in numerical field order when reducing the limit.
PDF JavaScript support varies by viewer. Test the form in the PDF applications your users will use, and validate the selection count on the receiving system if the limit is important.
In Acrobat, open All tools > Prepare a form. Name the radio button group Package and set its two export values to Five and Seven. Name the 15 individual checkbox fields Option1 through Option15.
Open All tools > Use JavaScript > Document JavaScripts, add a script, and paste the following code: function refreshOptions() { var packageField = this.getField('Package'); var choice = packageField.valueAsString; var limit = choice === 'Five' ? 5 : choice === 'Seven' ? 7 : 0; var count = 0; var i, field; for (i = 1; i <= 15; i++) { field = this.getField('Option' + i); if (field.valueAsString !== 'Off') { count++; if (count > limit) { field.value = 'Off'; count--; } } } for (i = 1; i <= 15; i++) { field = this.getField('Option' + i); field.readonly = field.valueAsString === 'Off' && count >= limit; } }
In Prepare a form, open each radio button and checkbox's Properties > Actions. For the Mouse Up trigger, choose Run a JavaScript and add: app.setTimeOut('refreshOptions()', 100); This schedules the count after the click has updated the field value.
Add the same app.setTimeOut('refreshOptions()', 100); action to the page's Page Open action, then save and reopen the PDF. Choose each package, reach its limit, clear a checkbox, and switch from Seven to Five to verify the behavior.

Review booking PDFs and Office files with WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with Office documents and viewing PDFs. It can help you review a booking form alongside related documents, but it does not replace Acrobat JavaScript configuration or guarantee enforcement of the selection limit.

Frequently Asked Questions
Can users select fewer than five or seven options?
Yes. The script sets a maximum based on the Package radio button. If the form requires exactly five or seven selections, add a separate validation check before submission.
What happens when someone changes from the seven-option package to the five-option package?
The script keeps the first five selected fields in Option1-to-Option15 order and clears any additional selections. Unchecked options remain disabled until the count falls below five.
Why does the form work in Acrobat but not in a browser?
Some browser PDF viewers do not support Acrobat JavaScript or form field actions. Test the saved form in the intended viewer and use server-side validation when accepting submitted data.
What should I change if my fields have different names?
In Prepare a form, check the field names and export values in Properties. Update Package, Five, Seven, Option, and the number 15 in the script to match your form's naming scheme.




