2 Replies Latest reply: Apr 9, 2012 1:58 PM by mj276 RSS

    Help with JavaScript validation of signatures based upon a form dollar amount

    mj276

      Greetings,

      First, I have no experience with JavaScript. 

       

      I have a PDF Form (Adobe Acrobat X Pro) with a dollar amount.  Based upon that dollar amount a certain signature (text box) must be completed.  Upon the mouse down action for the Save Form button, I need to validate that there is an entry for the correct signature (again, based upon the dollar amount).

       

      My weak pseudo code for this would be:

       

      If (dollarAmount > 0) and (dollarAmount < 100) and (signature1 == "") then printToScreen ("Requires Signature1")

      else if (dollarAmount > 101) and (dollarAmount < 200) and (signature2 == "") then printToScreen ("Requires Signature2")

      else if (dollarAmount > 201) and (signature3 == "") then printToScreen ("Requires Signature3")

       

      Any and all help would be appreciated.  Thank you.

        • 1. Re: Help with JavaScript validation of signatures based upon a form dollar amount
          try67 ACP/MVPs

          This script will do what you describe in your pseudo-code, but be aware it's not handling the following situations:

          - dollarAmount is empty

          - dollarAmount is exactly 100

          - dollarAmount is exactly 200

           

          var dollar = +this.getField("dollarAmount").value;

          var signature1 = this.getField("signature1").value;

          var signature2 = this.getField("signature2").value;

          var signature3 = this.getField("signature3").value;

           

          if (dollar>0 && dollar<100)

              if (signature1=="") {

                  app.alert("Requires Signature1");

              }

          } else if (dollar>101 && dollar<200) {

              if (signature2=="") {

                  app.alert("Requires Signature2");

              }

          } else if (dollar>201) {

              if (signature3=="") {

                  app.alert("Requires Signature3");

              }

          }

          • 2. Re: Help with JavaScript validation of signatures based upon a form dollar amount
            mj276 Community Member

            Thank you try67 that was very helpful.  As you hinted, I used <= in the code and it worked as I had hoped.