2 Replies Latest reply on Jan 23, 2014 12:08 PM by gkaiseril

    Set Document Actions

    natjnelson Level 1



      I simply want to notify a user that a required field is blank when they print or save the PDF.


      Based on other posts in the forum, I added the following JavaScript in Set Document Actions > Document Will Save and Document Will Print.


      function checkField(aField)


      if (!aField.required)


          return 1;

      if (aField.value == "") // empty field


          var msg = "No Required fields can be left empty.";


          return 0;


      return 1;

      } // end of function



      However, when I leave a required field blank, I don't receive the message.


      Is there an error in the JavaScript above?  Does it matter that some of the required fields are text and some are numbers?


      Thanks for any assistance,


        • 1. Re: Set Document Actions
          George_Johnson MVP & Adobe Community Professional

          That function is only a part of a script that you'd use for this. The function is passed an array of field objects and checks each one. So additional code you'd need would be code to create an array of field objects, code to call that function, and code that looks at the return value and does something based on its value. I suspect the thread that you got this code from will include this.

          • 2. Re: Set Document Actions
            gkaiseril MVP & Adobe Community Professional

            You will have to "walk" the array or run the test on each element of the array of field objects. You should change your code to return the result from testing all of the fields and not just an individual field.


            Also you may need to check that the field is field that can be tested for the "required" property and for some fields like check boxes or radio buttons you may need to perform some additional test.