5 Replies Latest reply on Jul 25, 2013 12:55 PM by rodeo1020

    Disable Field Printing when left as default

    rodeo1020

      Hello friends,

       

      I would like to disable a field from printing when it is left in it's default state. However, I would like it to print when and only when the user does enter some (any) information.

       

       

      This image is an example of the form. I would like "Your Company's Name" to not print if it is not filled in (so that users can fill in by hand, if they choose to do so)

      Screen shot 2013-07-25 at 12.05.21 PM.png

       

       

      Thank you again, internets!

        • 1. Re: Disable Field Printing when left as default
          mrfale67 Level 2

          I am thinking to 2 scripts:

          1) create a doc script (call it anything), delete the standard function you are given and just write:

          var f = this.getField("Txt_Company");

          f.display = display.noPrint;

           

          2) double-click the field, validation tab, custom script and enter:

           

          var f = event.target;

          if (f.value) {

                    f.display = display.visible;

          }

          else {

                    f.display = display.noPrint;

          }

           

          Script 1 will be your initialization while number 2 will change field display prop according to user's behaviour.

           

          ps: I am thinking that maybe the doc script should have a conditional check as well; otherwise, it will change the field prop unconditionally at doc open event;

          1 person found this helpful
          • 2. Re: Disable Field Printing when left as default
            gkaiseril MVP & Adobe Community Professional

            I would use a custom validation script:

             

            var field = event.target;

            field.display = display.visible;

            if (field.value.toLoserCase() == "your company name") {

                      field.display = display.noPrint;

            }

            1 person found this helpful
            • 3. Re: Disable Field Printing when left as default
              mrfale67 Level 2

              GKaiseril,

              do you mean a custom validation script can work as an initialization one as well?
              Please let me know.
              Thanks

              1 person found this helpful
              • 4. Re: Disable Field Printing when left as default
                gkaiseril MVP & Adobe Community Professional

                No. the validation script only runs if the form field is changed. You can set the initial state of the form field when you create the form.

                 

                You should change the action around;

                 

                var field = event.target;

                field.display = display.noPrint; // assume do not print;

                if (field.value.toLoserCase() != "your company name") {

                   // name not default value, then display & print;

                          field.display = display.visible;

                }

                 

                Or for a more generalized approach, set the default value and use that for testing.

                 

                var field = event.target;

                field.display = display.noPrint; // assume do not print;

                if (field.value.toLowerCase() != field.devaultValue.toLowerCase()) {

                   // name not default value, then display & print;

                          field.display = display.visible;

                }

                • 5. Re: Disable Field Printing when left as default
                  rodeo1020 Level 1

                  Wow! Thank you guys, I'm impressed.