1 Reply Latest reply on Mar 25, 2012 9:38 AM by George_Johnson

    Report error when using combo box and one text field is empty

    alexalexao

      I'm building an interactive pdf in adobe pro 9. My problem is the following: I have one text field where you can enter a numeric code and that is used to populate another text field when I choose an option on one combo box.For example: suppose I write the code 123 in the text field "A" and that the combo box has two options ("data" and "-"). When I select "-", another text field "B" is empty, while when I select "data" i populate the text field "B" using the code entered "A" with the text "data_123". In order to do this I use the standard javascript code in the Format>Custom tab of the combo-box.

       

      My questions are:

       

      - how can I prevent the pdf to proceed selecting an option in the combo box when the field "A" is empty?

       

      - how can I update the field "B" every time that I change the text in "A"? I found that the text is "B" is updated only when I press the selection in the combo box.

        • 1. Re: Report error when using combo box and one text field is empty
          George_Johnson MVP & Adobe Community Professional

          You can set the combo box to read-only in the Validate event of the A field:

           

          // Validate script for text field

          getField("combo1").readonly = !event.value;

           

           

          To update the value of B when A changes, you can expand the script above to something like:

           

          // Validate script for text field

          var f1 = getField("combo1");

          var f2 = getField("B");

           

          // If there is an entry in the A field...

          if (event.value) {

              f1.readonly = false;  // Make sure the combo box is activated

              f2.value = f1.value === "-" ? "" : "fa.value + event.value;  // Update the value of field B

          } else {

              f1.readonly = true;  // Deactivate the combo box

              f2.value = f2.defaultValue;  // Reset field B

          }

           

           

          You might also want to reset the combo box somewhere in there, but it's not clear to me when you would want to do that.