6 Replies Latest reply on Jun 25, 2013 9:08 AM by crystaltroiano

    Validate 2 fields

    crystaltroiano

      I have two fields I need to have validated (equipment and serial numbers). Once those are filled out the user will use a dropdown(tonnage) to select a number that will return them a specified dollar amount (working fine). My issue is validating those two fileds and if they are not filled out the dropdown needs to be blank. I have the following code that I believe to be correct. I am calling this function in the validate section of the dropdown field and NOTHING is happening. I'm at my whits end  - any suggestions are helpful.

       

       

      function getEquip() {

          var rowName = event.target.name;

          var rowNum = rowName.substr(rowName.length - 5, 5);

       

          if (this.getField("Equipment Description" + rowNum).value == " " && this.getField("Equipment Serial" + rowNum).value == " ") {

            this.getField("Unit Tonnage" + rowNum).value = " ";

          }

       

          if (this.getField("Equipment Description" + rowNum).value == " ") {

            

              app.alert('Please enter an equipment description');

          }

       

          if (this.getField("Equipment Serial" + rowNum).value == " ") {

            

              app.alert('Please enter an equipment serial number');

          }

       

       

      }

       

       

      Image of PDF

        • 1. Re: Validate 2 fields
          try67 MVP & Adobe Community Professional

          Code that is inside a function will only execute when the function is

          called... So you can either add a call to the function in the Validate

          event, like this:

          getEquip()

           

          Or remove the function definition altogether.

           

          I would do the former and place the actual function as a doc-level script.

          • 2. Re: Validate 2 fields
            crystaltroiano Level 1

            Yes, I am calling this function in the validate section of the dropdown field as

             

            getEquip();

            • 3. Re: Validate 2 fields
              try67 MVP & Adobe Community Professional

              OK. 2 points:

              - You need to access event.value to check the newly selected value of the drop-down that triggered the event.

              - Make sure you tick the box that commits the selected value immediately for that box to make sure that the script is triggered at the moment a selection is made (otherwise it will only launch when you exit the field).

              • 4. Re: Validate 2 fields
                crystaltroiano Level 1

                I checked the box that commits the selection.

                 

                I'm not sure about accessing 'event.value' to check the value of the field. The dropdown operates on a different code (below) and that part is working perfectly. It's just the checking part that won't work.

                 

                function getIncentives() {
                var rowName = event.target.name;
                var rowNum = rowName.substr(rowName.length-5,5);
                var tons = this.getField("Unit Tonnage" + rowNum).value;

                if (tons == "4") {
                  this.getField("Incentive" + rowNum).value = 250;
                }
                if (tons == "5") {
                  this.getField("Incentive" + rowNum).value = 250;
                }
                if (tons == "6") {
                  this.getField("Incentive" + rowNum).value = 265;
                }
                if (tons == "7.5") {
                  this.getField("Incentive" + rowNum).value = 287;
                }
                if (tons == "8") {
                  this.getField("Incentive" + rowNum).value = 295;
                }
                if (tons == "9") {
                  this.getField("Incentive" + rowNum).value = 310;
                }
                if (tons == "10") {
                  this.getField("Incentive" + rowNum).value = 325;
                }
                if (tons == "11") {
                  this.getField("Incentive" + rowNum).value = 340;
                }
                if (tons == "12.5") {
                  this.getField("Incentive" + rowNum).value = 362;
                }
                if (tons == "15") {
                  this.getField("Incentive" + rowNum).value = 400;
                }
                if (tons == "17.5") {
                  this.getField("Incentive" + rowNum).value = 437;
                }
                if (tons == "20") {
                  this.getField("Incentive" + rowNum).value = 475;
                }
                if (tons == "25") {
                  this.getField("Incentive" + rowNum).value = 550;
                }
                if (tons == "30") {
                  this.getField("Incentive" + rowNum).value = 625;
                }
                if (tons == "35") {
                  this.getField("Incentive" + rowNum).value = 700;
                }
                if (tons == "40") {
                  this.getField("Incentive" + rowNum).value = 775;
                }
                if (tons == " ") {
                  this.getField("Incentive" + rowNum).value = "";
                }

                    }

                • 5. Re: Validate 2 fields
                  try67 MVP & Adobe Community Professional

                  Sorry, but I'm not really understanding what you're doing... It might be

                  better if you could share the file, either via a file-sharing website, or

                  you can send it to me directly at try6767@gmail.com .

                  • 6. Re: Validate 2 fields
                    crystaltroiano Level 1

                    I will do that. There are some client issues with sending the file to someone not in the company, so I will make the file on a blank page and get it right over to you. Thank you for your help.