7 Replies Latest reply on Sep 6, 2013 3:33 PM by nmara

    Required Combo Box field with User option for custom text

    SICreation

      I'm using Acrobat XI Professional

      My Problem:

      I created a combo box with several item choices, and the option for users to enter custom text.  I would like this combo box to be REQUIRED, however, since I have the option checked for user custom text, and a combo box uses the item in a list select as a DEFAULT, it recognizes that an item was choosen and the form submits without any changes selected.

       

      My Workaround:

      Currently I have the default item as follows:  "...select from list or type specific trip type".  I also created a tooltip with instructions.  But it doesn't help if my users will ignore these notes and the form is able to submit without changing the default.

       

       

      My Question: 

      Is there a javascript or custom keystroke script that I can add to this combo box to throw an error when the DEFAULT item was not changed in the field?

        • 1. Re: Required Combo Box field with User option for custom text
          MichaelN Level 3

          You could create a Submit button which has the following mouse up script:

           

               var f = this.getField("myComboBox").value;

               if (f == "Default")

               app.alert("Please make a selection from the menu.");

           

           

          Replace "myComboBox" in line 1 with the name of your combo box, and make the export value of "...select from list or type specific trip type"  = "Default".

           

          When they try to submit the form without choosing a trip type, they will get an alert message.

          • 2. Re: Required Combo Box field with User option for custom text
            nmara

            Thanks a lot Michael.  I attempted this approach, with some slight changes.  We have multiple combo boxes which are required so I used your script, but just created separate variables for each combo box.  Works great, however the submit button has two actions set up: Run a JavaScript and Submit a form.  I was hoping it would not submit the form until the combobox entries were entered, but instead it opens an email with the form attached right after you click OK to the alert message(s).  I have tried setting your script at the combo box itself, but that only works if a user mouses over the box,. I have tried using your script as validation .. and that did not work.  I even tried opening up the JavaScript editor to apply it at a document level but that did not work either.  My last attempt was to create a hidden button to validate the values, but since a user does not see the button it is useless as the actions are all based on mouse actions.  Ughh ... 

             

            I searched the web and found the following script, however that just cleared the default value, even when I selected the correct value, so that needs to be modified somewhat.

             

            // THIS SCRIPT REMOVES ALL VALUES IN THE DROPDOWN SO THAT REQUIRED WILL WORK.

            var f;

            f = getField("YourDropdownBoxFieldName");

            f.editable = true;

            f.value = "";

            f.setAction("Validate", "event.rc = false;");

            f.editable = false;

            f.setAction("Validate", "event.rc = true;");

             

             

            Is there something simple I am missing?

            Thanks in advance,

            Nat

            • 3. Re: Required Combo Box field with User option for custom text
              gkaiseril MVP & Adobe Community Professional

              The following script will work on any field except button and signature for checking if the value of the field is equal to the default value of the field:

               

               

              if(f.type != "button" && != "signature" && f.value == f.defaultValue)

                   app.alert("Please make a selection from the menu.");

               

              The default value of the field for text fields is set on the Options tab "Default value" entry. For check boxes and radio buttons it is "Off" or the "Default is checked". For list boxes and drop down boxes it is the highlighted option when the field UI is closed.

               

              There is no "editable" property in Acrobat JavaScript. Note that Acrobat JavaScript is not completely the same as Web page JavaScript.

               

              Field Properties

               

              Field methods

              • 4. Re: Required Combo Box field with User option for custom text
                nmara Level 1

                Thanks GK. so I am guessing by your response that the Script I found on the website was false as it referenced a "f.editable" property. No problems there. I actually used the code by MichaelN above, and it validated correctly, unfortunately it still allows submission of an incomplete form.  My question to you, is does your code get assigned at document level, or should that be applied to the submit button, combo box, etc??

                 

                lastly, what I thought might work was to have 2 buttons:

                1. Validate - runs the script and returns alert(s)
                2. Submit- initially hidden or greyed out until validate button has been run

                 

                Sorry not very proficient in Acroforms.  On a side note, I got an error when clicking on the "Field methods" link in your post.

                 

                regards

                • 5. Re: Required Combo Box field with User option for custom text
                  gkaiseril MVP & Adobe Community Professional

                  It should work in the field's vaiidation. It does show one possible way to test all fields except button and signature fields which should be done as one of the last steps of processing a form with required fields before saving, printing, or submitting the form.

                   

                  Yes submitting a form to a web JavaScript page will check for completed fields but the response for an error can be cryptic to the end user. This would allow a more user friendly check.

                  • 6. Re: Required Combo Box field with User option for custom text
                    nmara Level 1

                    Thanks so much.  I posted your code in validation on one of the combo box validation field.  It gave me a Syntax error, and I assumed that was becuase I did not have anything called "Button" or a signature field.  I edited the code to the following: 

                     

                    if(f.type != "Submit" && f.value == f.defaultValue)

                         app.alert("Please make a selection from the menu.");

                     

                    I did not get any syntax errors but nothing happened.

                     

                    Maybe my best bet is to to make this form in Lifecycle designer, unless this is a simple modification.

                     

                    Much appreciated,

                    Nat

                    • 7. Re: Required Combo Box field with User option for custom text
                      nmara Level 1

                      Thanks to all who responded.  It would be nice to know if this can be done using Acroforms, as opposed to Lifecycle Designer forms.  I just think that editing an Acroform setting properties on different tabs is easier when compared to palletes in LifeCycle.  That being said, it is much more difficult to enforce blank fields in anything other than a text box when compared to LifeCycle form.  The script was great at warning about fields with default values but it still allowed an incomplete form to be submitted, despite the warnings.

                       

                      My solution was twofold:

                      1. Create the form in Lifecycle Designer, as this will allow you to set the list boxes to required with empty default values, and will not allow you to email a form until they are all filled out.
                      2. The one slight modification I had to make was to not include the default SUBMIT button as that will not send a PDF.  It sent a data.XML file instead.  My workaround was to create a new BUTTON and on the FIELD tab chose “Submit” under CONTROL TYPE.  In the SUBMIT tab enter Mailto: followed by an e-mail, and more importantly select “PDF”  in SUBMIT AS box.

                       

                      Now I have a form that enforces required fields, and sends a full PDF file.

                       

                      Now if only I had figured this out yesterday …. J