6 Replies Latest reply on Mar 30, 2016 2:20 PM by RSpider

    Why is Acrobat not saving javascript events???


      HELP! I'm trying to enter a code with a specific  text field, and Acrobat won't save it... Very frustrating!...


      Here's what's happening:


      Select a field (already been saved), go to properties; Go to format, choose "Custom", choose "Custom Keystroke Script", select "Edit...", Javascript Editor opens...


      Paste in code:


      (if ( event.fieldFull || event.willCommit ) this.getField("*name of field*").setFocus();


      (Subsituting the name of the field of course, checking name and doc is saved with the name in place)


      Click the "OK" button, and Acrobat returns me to the "Format" tab, as if I had entered nothing! It worked once, but I haven't been able to do it again... And naturally, I have a deadline bearing down on me...


      iMac mid 2010, 3.2, 14GB, OSX 10.10.3, Acrobat XI and DC

        • 1. Re: Why is Acrobat not saving javascript events???
          Karl Heinz Kremer Adobe Community Professional

          There is a problem with your script: The initial "(" is wrong - with that in place, you should get a syntax error when you try to save your script. Without that, the script should be saved correctly (and I just verified that it does). Can you save other scripts?

          • 2. Re: Why is Acrobat not saving javascript events???
            WmChrisHoward Level 1

            No, not able to save other scripts and I'm led to believe that there is corruption in the text fields... I created new text fields from scratch and they worked as expected.


            All three places I used this script, also all keyboard scripts did not work in the original fields. These fields were all created by Acrobat scanning a PDF made using InDesign, so I'm wondering if it has something to do with being auto-made by Acrobat? The world may never know...


            About the script itself, that script does work, but I found a better one to accomplish the same thing...


            The goal is to link the two fields together so that when the first fills up with text the user can continue typing into the second field.


            What I found was this:


            var x=this.getField ("*name of first field*");

            if (event.fieldFull) {

                getField("*name of second field*").setFocus();



            Works as good as it will get.... I think...


            Hey, thanks for the help!

            • 3. Re: Why is Acrobat not saving javascript events???

              I am having this exact same problem.  I'm trying to add a Validation script to a Combo Box (DropDown menu) that will hide one field if a particular value is selected from the list. Otherwise, I want the field visible but not printable.  For some reason, when I enter the script below and click OK, the script is not saved.


              if (event.value == "Full-Time (PF)")
              this.getField("Field 001").display = display.hidden;

              else if (event.value != "Full-Time (PF)")
              this.getField("Field 001").display = display.noPrint;


              • 4. Re: Why is Acrobat not saving javascript events???
                gkaiseril MVP & Adobe Community Professional

                Any errors in the JavaScript console?


                It appears you could simplify your coding. Is an expression is false then then is no need to retest it for the false condition.



                console.println("event.value = " + event.value);

                var oField = this.getField("Field 001");

                if(oField == null) app.alert("Field 001 not found", 1, 0);


                if (event.value == "Full-Time (PF)")

                console.println("Full-Time is true");

                // true result;

                this.getField("Field 001").display = display.hidden;



                // false result;

                console.println("Not Full-Time");
                this.getField("Field 001").display = display.noPrint;



                You could also add some debugging statements to check that the values you thing you are getting are what you they are and your logical statements are working as expected.

                • 5. Re: Why is Acrobat not saving javascript events???
                  RSpider Level 1

                  Thanks for your input!  I'm going mad trying to figure out why I cannot add any custom scripts to this field.  I've even tried adding different test scripts that I could successfully add to other fields, but for some reason this field and one other field simply won't take any custom scripts -- validation scripts, calculation scripts, or format scripts.  I even tried deleting it and recreating the field, to no avail. 

                  • 6. Re: Why is Acrobat not saving javascript events???
                    RSpider Level 1

                    I seem to have solved my own question.  I deleted the dropdown field, saved the file, closed acrobat, re-opened the file, created a new dropdown field with a different name, and was able to add the following script:


                    if(event.value =="Full-Time (PF)") {

                    this.getField("Field 001").display = display.hidden;
                    } else {
                    this.getField("Field 001").display = display.noPrint;


                    All seems to be working as expected.  Thanks for taking the time to help.