14 Replies Latest reply on Dec 29, 2017 1:21 PM by lucy61176

    Require certain fields based on combo box selection

    lucy61176

      I have created a dynamic form in Acrobat DC where selecting a button will make certain fields required and/or suggested (using green border around the field). I was able to do this successfully with everything but the combo box. I need to be able to make certain fields (text and checkboxes) required or suggested based on the selection in the combo box. I haven't been able to find exactly what I'm looking for googling this. Any help is greatly appreciated!

        • 1. Re: Require certain fields based on combo box selection
          try67 MVP & Adobe Community Professional

          There shouldn't be an issue to do it, although it's possible the built-in required fields validation will ignore these fields.

          • 2. Re: Require certain fields based on combo box selection
            lucy61176 Level 1

            Sorry, but I don't know how. I am only able to get it to work if I choose something from the combo box, go to another field, and go back to the combo box. When I click on the dropdown arrow, that is when it works. The javascript I have under Mouse Up is:

             

            var PrimaryCARESAccess = this.getField("PrimaryCARESAccess");

            var IMDropdown = this.getField("IMDropdown");

            if (PrimaryCARESAccess.value == "1") {IMDropdown.required = true;}

            • 3. Re: Require certain fields based on combo box selection
              try67 MVP & Adobe Community Professional

              Use this code as the validation script of the drop-down:

              var IMDropdown = this.getField("IMDropdown");

              if (event.value == "1") {IMDropdown.required = true;}

               

              Also, make sure to tick the option to commit the selected value immediately, under Properties - Options.

              • 4. Re: Require certain fields based on combo box selection
                lucy61176 Level 1

                Sorry but it doesn't work. It only works when I choose the item in the combo box and then click on the combo box a second time.

                • 5. Re: Require certain fields based on combo box selection
                  try67 MVP & Adobe Community Professional

                  Did you move the code to the Validation script?

                  • 7. Re: Require certain fields based on combo box selection
                    try67 MVP & Adobe Community Professional

                    And just to clarify, the combo-box is "PrimaryCARESAccess", right?

                     

                    If so, can you share the file with us (via Dropbox, Google Drive, Adobe Cloud, etc.)?

                    • 8. Re: Require certain fields based on combo box selection
                      lucy61176 Level 1

                      Here is the file: f00476 12 20 17 DRAFT.pdf - Google Drive

                       

                      I'm trying to get the basic code and instructions so that I can use it to create different scenarios for the various selections in the combo box.

                      • 9. Re: Require certain fields based on combo box selection
                        try67 MVP & Adobe Community Professional

                        OK, I see the issue. You need to use the display value instead of the export value when using event.value.

                        So instead of:

                        if (event.value == "1")

                        Use:

                        if (event.value == "A-FSET")

                        1 person found this helpful
                        • 10. Re: Require certain fields based on combo box selection
                          lucy61176 Level 1

                          Yes! That did the trick! Thank you very much. I was able to incorporate all the selections.

                           

                          If the person filling this out chooses one and then decides it was the wrong choice, is there code so that the required/suggested fields associated with the first choice are "reset"?

                          • 11. Re: Require certain fields based on combo box selection
                            try67 MVP & Adobe Community Professional

                            Sure. You can use something like this:

                            this.resetForm(["Field1", "Field2", "Field3"]);

                            • 12. Re: Require certain fields based on combo box selection
                              lucy61176 Level 1

                              I guess reset is the wrong word to use. I'm looking at undoing required and suggested (fields with green border). For example, if "C-Children First" is selected but the person actually wanted "B-Resource Specialist/Job Coach," how would I change "IndividualOffice" from being required to not being required? Reseting a form doesn't change the required property.

                               

                               

                              // mark required

                               

                              if (event.value == "C-Children First") {IndividualOffice.required = true; OfficeNumber.required = true; IndOffice.required = true;}

                              if (event.value == "Y-Transitional Jobs") {IndividualOffice.required = true; OfficeNumber.required = true; IndOffice.required = true;}

                              if (event.value == "H-Receptionist-IM") {IMDropdown.required = true;}

                              if (event.value == "M-IM Worker") {IMDropdown.required = true;}

                              if (event.value == "U-IM Supervisor") {IMDropdown.required = true;}

                               

                              // mark suggested

                               

                              1. color.green= ["RGB",0,1,0];

                              if (event.value == "A-FSET") {Region1.strokeColor = ["RGB",0,1,0]; Region2.strokeColor = ["RGB",0,1,0]; Region3.strokeColor = ["RGB",0,1,0]; Region4.strokeColor = ["RGB",0,1,0]; Region5.strokeColor = ["RGB",0,1,0]; Region6.strokeColor = ["RGB",0,1,0]; Region7.strokeColor = ["RGB",0,1,0]; Region8.strokeColor = ["RGB",0,1,0]; Region9.strokeColor = ["RGB",0,1,0]; Region10.strokeColor = ["RGB",0,1,0]; Region11.strokeColor = ["RGB",0,1,0];}

                              if (event.value == "A-Job Coach") {FSC.strokeColor = ["RGB",0,1,0]; MIEC.strokeColor = ["RGB",0,1,0]; MIN.strokeColor = ["RGB",0,1,0]; MIS.strokeColor = ["RGB",0,1,0]; MIWC.strokeColor = ["RGB",0,1,0]; NorthCentral.strokeColor = ["RGB",0,1,0]; Northeast.strokeColor = ["RGB",0,1,0]; Northwest.strokeColor = ["RGB",0,1,0]; Southeast.strokeColor = ["RGB",0,1,0]; Southwest.strokeColor = ["RGB",0,1,0]; Western.strokeColor = ["RGB",0,1,0];}

                              if (event.value == "B-Resource Specialist/Job Coach") {FSC.strokeColor = ["RGB",0,1,0]; MIEC.strokeColor = ["RGB",0,1,0]; MIN.strokeColor = ["RGB",0,1,0]; MIS.strokeColor = ["RGB",0,1,0]; MIWC.strokeColor = ["RGB",0,1,0]; NorthCentral.strokeColor = ["RGB",0,1,0]; Northeast.strokeColor = ["RGB",0,1,0]; Northwest.strokeColor = ["RGB",0,1,0]; Southeast.strokeColor = ["RGB",0,1,0]; Southwest.strokeColor = ["RGB",0,1,0]; Western.strokeColor = ["RGB",0,1,0];}

                              if (event.value == "H-Receptionist-W-2") {FSC.strokeColor = ["RGB",0,1,0]; MIEC.strokeColor = ["RGB",0,1,0]; MIN.strokeColor = ["RGB",0,1,0]; MIS.strokeColor = ["RGB",0,1,0]; MIWC.strokeColor = ["RGB",0,1,0]; NorthCentral.strokeColor = ["RGB",0,1,0]; Northeast.strokeColor = ["RGB",0,1,0]; Northwest.strokeColor = ["RGB",0,1,0]; Southeast.strokeColor = ["RGB",0,1,0]; Southwest.strokeColor = ["RGB",0,1,0]; Western.strokeColor = ["RGB",0,1,0];}

                              if (event.value == "J-Financial Employment Planner (FEP) Supervisor") {FSC.strokeColor = ["RGB",0,1,0]; MIEC.strokeColor = ["RGB",0,1,0]; MIN.strokeColor = ["RGB",0,1,0]; MIS.strokeColor = ["RGB",0,1,0]; MIWC.strokeColor = ["RGB",0,1,0]; NorthCentral.strokeColor = ["RGB",0,1,0]; Northeast.strokeColor = ["RGB",0,1,0]; Northwest.strokeColor = ["RGB",0,1,0]; Southeast.strokeColor = ["RGB",0,1,0]; Southwest.strokeColor = ["RGB",0,1,0]; Western.strokeColor = ["RGB",0,1,0];}

                              if (event.value == "N-FEP") {FSC.strokeColor = ["RGB",0,1,0]; MIEC.strokeColor = ["RGB",0,1,0]; MIN.strokeColor = ["RGB",0,1,0]; MIS.strokeColor = ["RGB",0,1,0]; MIWC.strokeColor = ["RGB",0,1,0]; NorthCentral.strokeColor = ["RGB",0,1,0]; Northeast.strokeColor = ["RGB",0,1,0]; Northwest.strokeColor = ["RGB",0,1,0]; Southeast.strokeColor = ["RGB",0,1,0]; Southwest.strokeColor = ["RGB",0,1,0]; Western.strokeColor = ["RGB",0,1,0];}

                              if (event.value == "P-Resource Specialist") {FSC.strokeColor = ["RGB",0,1,0]; MIEC.strokeColor = ["RGB",0,1,0]; MIN.strokeColor = ["RGB",0,1,0]; MIS.strokeColor = ["RGB",0,1,0]; MIWC.strokeColor = ["RGB",0,1,0]; NorthCentral.strokeColor = ["RGB",0,1,0]; Northeast.strokeColor = ["RGB",0,1,0]; Northwest.strokeColor = ["RGB",0,1,0]; Southeast.strokeColor = ["RGB",0,1,0]; Southwest.strokeColor = ["RGB",0,1,0]; Western.strokeColor = ["RGB",0,1,0];}

                              • 13. Re: Require certain fields based on combo box selection
                                try67 MVP & Adobe Community Professional

                                Before your if-statements set the fields as not required, like this:

                                 

                                IndividualOffice.required = false;

                                OfficeNumber.required = false;

                                IndOffice.required = false;

                                1 person found this helpful
                                • 14. Re: Require certain fields based on combo box selection
                                  lucy61176 Level 1

                                  This works great! Thank you so much for your help!