Skip to main content
Participant
March 9, 2017
Answered

PDF form with Adobe Acrobat Pro DC- limit the number of check boxes selected

  • March 9, 2017
  • 1 reply
  • 1738 views

Hi there.

I have created a PDF form with Adobe Acrobat Pro DC.

This example is a catering form where there are 4 meats to choose from. The customer can only select two meats. If they try to select a third meat, then I want it to deselect the meat that they just tried to select. I tried this using meat1.meat2,meat3 and meat4 as checkboxes. I am not familiar with javascript, so please can you type out what I need to.

thank you so much

This topic has been closed for replies.
Correct answer marcusb58143956

Thank you so much, this works perfectly!

1 reply

try67
Community Expert
Community Expert
March 9, 2017

It was a bit tricky (especially the part where the value is rejected), but I think I was able to do it.

Create a new (hidden) text field and use this code as its custom validation calculation script:

if (event.source && /^meat\d$/.test(event.source.name)) {

    var counter = 0;

    for (var i=1; i<=4; i++) {

        if (this.getField("meat"+i).value!="Off")

            counter++;

    }

    if (counter>2) {

        app.alert("Error! Maximum 2 meats are allowed.");

        this.resetForm([event.source.name]);

    }

}

try67
Community Expert
Community Expert
March 9, 2017

See my correction above...