9 Replies Latest reply on Sep 27, 2016 11:39 PM by somebunny

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

    somebunny

      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.

        • 1. Re: Acrobat XI Pro Form: at least one of six checkboxes is required to be checked
          try67 MVP & Adobe Community Professional

          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.

          • 2. Re: Acrobat XI Pro Form: at least one of six checkboxes is required to be checked
            somebunny Level 1

            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.    : )

            • 3. Re: Acrobat XI Pro Form: at least one of six checkboxes is required to be checked
              somebunny Level 1

              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[i]).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!

              • 4. Re: Acrobat XI Pro Form: at least one of six checkboxes is required to be checked
                somebunny Level 1

                oops ...  the last line of your code should not have an 'a' in it...   I must have hit that by mistake.

                 

                last line of code is really:

                 

                event.value = v;

                • 5. Re: Acrobat XI Pro Form: at least one of six checkboxes is required to be checked
                  somebunny Level 1

                  Hi Try67,

                   

                  I just figured out the last part of my question regarding making the checkboxes be highlighted in red, when at least one of them is not checked.

                   

                  I made the Hidden Text Field be "not hidden."  I stretched it to fit the length of the row of checkboxes, so that they were all encompassed by it.  Then I sent that text field "behind" the row of checkboxes.  Now, when none of the boxes are checked, the red line of the text field goes around the whole row of checkboxes, showing that they are the unsatisfied required group.

                   

                  Also, there was some text in the textfield, based on the calculation javascript that we had attached to the text field.  When all is well, it says "OK" inside the text field.  I went to the properties of the text field and changed the text color from black to white, so it won't show up.

                   

                  Anyways, thank  you very much for your help.  Your original code that I found online is what helped me get going.

                   

                  I appreciate it very much.

                   

                  Regards.   : )

                  • 6. Re: Acrobat XI Pro Form: at least one of six checkboxes is required to be checked
                    try67 MVP & Adobe Community Professional

                    That's a neat solution. Glad you found it and shared it with us...

                    • 7. Re: Acrobat XI Pro Form: at least one of six checkboxes is required to be checked
                      try67 MVP & Adobe Community Professional

                      PS. I assume you found it already, but if you didn't you can set the default value of a text field via its Properties - Options tab.

                      1 person found this helpful
                      • 8. Re: Acrobat XI Pro Form: at least one of six checkboxes is required to be checked
                        somebunny Level 1

                        Hi try67,

                         

                        Actually, at the time you wrote this about the Properties / Options tab, I had not found it still.  So, thank you for giving me that information.  Can't believe I didn't see it, until you told me where it was.  Kind of obvious.   : P

                         

                        Thanks.   : )