3 Replies Latest reply on Dec 13, 2012 2:30 PM by Trevellian2

    Validating forms in acrobat

    Trevellian2

      Hi so I'm a little rusty with my javascript and I'm trying to get a button to send an email if the following conditions are met:

       

      if radiobutton "A" is checked then

         field "equiv" is  null/empty

           throw up message

        field "equiv" is NOT null/empty

           move on to next step

       

      checkbox "accept" is checked.

         send email

      checkbox "accept" is NOT checked

        throw up message

       

      So far I've just been trying to smash together some code but it just isn't working. Should I have them both in the same "javascript" as acrobat calls them?

       

       

      if ((this.getField("partc").value != "c") && (this.getField("equiv").value == null){

          app.alert("Please fill out this field", 1);

        }else{

         

      }

       

      if (this.getField("accept").value != "Off") {

      this.mailDoc({

       

              bUI: false,

       

              cTo: "person@place.com",

       

              cCC: "",

              cSubject: "Application for reduced level of service",

       

              cMsg: ""

       

          });

      } else {

        app.alert("Please check the 'I accept' box to email this form.", 1);

      }

       

      Would appreciate any help, thanks!

        • 1. Re: Validating forms in acrobat
          Trevellian2 Level 1

          Figured it out, this was pretty basic stuff so I just needed to play around with it a bit:

           

          if (this.getField("partbc").value != "b" ) {

              if (this.getField("equiv").value != "") {

                 

              } else {

                app.alert("If you selected Part C you must enter a value in the field next to the checkbox", 1);

              }

          }

           

          if (this.getField("accept").value != "Off") {

            this.mailDoc({

           

                  bUI: false,

           

                  cTo: "nfontaine@winnipeg.ca",

           

                  cCC: "",

                  cSubject: "Application for reduced level of service",

           

                  cMsg: ""

           

              });

          }else{

            app.alert("Please check the box above this button to confirm your information.", 1);

          }

          • 2. Re: Validating forms in acrobat
            try67 MVP & Adobe Community Professional

            Don't you want to make the mailing of the document dependent on the first part of the code?

            Also, instead of using an empty if-block, just change the condition to == (equals), and get rid of the else-block.

            • 3. Re: Validating forms in acrobat
              Trevellian2 Level 1

              I do, but I had a deadline to meet so as soon as it met the requirements I stopped touching it and ran with it.

               

              I'm optimizing it now, just not used to javascript so little things like that escape me.

               

              if (this.getField("partbc").value != "b" ) {

                  if (this.getField("equiv").value == "") {

                    app.alert("If you selected Part C you must enter a value in the field next to the checkbox", 1);

                  }

              }

               

              That looks better, working on incorporating the email into the first chunk of code.