6 Replies Latest reply on Aug 7, 2015 2:58 AM by jamesc10100

    Script for mandatory checkboxes


      Recently I have been editing a PDF with checkboxes for steps in a process. Basically, these will just be used when going through the process to check off each individual step as the user goes along. There has been a requirement raised to prevent the checkboxes from being checked until the previous one has been marked off. So checkbox 2 cannot be checked until checkbox 1 has been checked, and 3 cannot be checked until 2 is checked etc.


      Could anyone offer some advice on a script for this? My knowledge of scripting is fairly limited so any help would be greatly appreciated! Thank you.

        • 1. Re: Script for mandatory checkboxes
          gkaiseril MVP & Adobe Community Professional

          Since both check boxes and radio buttons have a value of "Off" when not selected, any incomplete group of buttons or an individual check box will have a value of "Off".


          You want to set all the check boxes except box 1 to read only. Then for the mouse up event for check box one you want the following script to run:


          if(event.target.value != "Off") this.getFeild("checkbox 2").readonly = false;

          else {

          this.getFeild("checkbox 2").readonly = false;

          this.getField("checkbox 2") = "Off";



          And so on down the line.


          With some prior planning the script could be reduced to a function and

          • 2. Re: Script for mandatory checkboxes
            jamesc10100 Level 1

            Hi @GKaiseril


            I do understand that the value is "Off" on the checkboxes. What I want to prevent is a user deciding to say, skip step 5 and go straight to step 15 in the process. So I would like to lock down all check boxes until the previous one has been checked, or is marked as "On".

            • 3. Re: Script for mandatory checkboxes
              gkaiseril MVP & Adobe Community Professional

              If all boxes except box 1 is set to read only, how can someone skip to box 15 and check it since it is read only.


              As one checks a check box only the next check box is made read write or unlocked. So unless check box 14 has been checked, box 15 will remain read only and cannot be selected.


              Unless one needs to check for a very specific item from an exclusionary group of check boxes or radio buttons the most reliable test is to check for the "Off" value or the value not being "Off".

              • 4. Re: Script for mandatory checkboxes
                JoelGeraci_Datalogics Level 3

                My advice would be to not put any script in the checkboxes at all. Create a hidden, calculated, field that manages the readonly property of the checkboxes. You also might consider creating the checkboxes as an array (check.0, check.1, check.2) - that'll make it easier to loop through them all.



                • 5. Re: Script for mandatory checkboxes
                  George_Johnson MVP & Adobe Community Professional

                  One thing you'll have to decide is what to do if the user checks some check boxes in the correct sequence but then decides to uncheck one (or more) of them. What should happen then?

                  • 6. Re: Script for mandatory checkboxes
                    jamesc10100 Level 1

                    Thank you everyone for the help.


                    I eventually managed to find a piece of code that would show the next hidden check box but also hide the checkbox if the one before is unchecked. Below is the code I used just in case anyone is interested.


                    var nHide = event.target.isBoxChecked (0) ?display.visable:display.hidden;


                    this.getField("Check Box2").display = nHide;


                    Again thanks for the help.


                    - James