3 Replies Latest reply on May 15, 2015 7:39 AM by try67

    Required date based on Order Date

    Ebnul.nao Level 1

      Hello,

       

      I have a PDF form with 2 date field. there's order date & required date. Is it possible to program something that makes it impossible to require date in LESS than 5 weeks?

      Example, someone put in the order date : 05/20/2015   if he puts 06/01/2015 in required date an error message appear saying that the minimum leadtime is 5 weeks?

       

      Thank you for your help in advance.

        • 1. Re: Required date based on Order Date
          try67 MVP & Adobe Community Professional

          Yes, it's possible. You can use this code as the custom validation script of the "required date" field:

           

          if (event.value) {
              var orderDateString = this.getField("Order Date").valueAsString;
              if (orderDateString=="") {
                  app.alert("You must first specify the order date.");
                  event.rc = false;
              } else {
                  var orderDate = util.scand("mm/dd/yyyy", orderDateString);
                  var requiredDate = util.scand("mm/dd/yyyy", event.value);
                  if ((requiredDate-orderDate)<(35*86400000)) {
                      app.alert("The required date must be at least 5 weeks after the order date.");
                      event.rc = false;
                  }
              }
          }
          

           

          It might also be a good idea to reset the value of the Required Date field when the value of the Order Date is changed.

          • 2. Re: Required date based on Order Date
            Ebnul.nao Level 1

            Hi try67,

             

            Thank you for your help.

            It works like a charm.

            Just one more question.

            Is there any way to blank required date field after OK in JavaScript warning window?

             

            Regards,

            Ebnul

            • 3. Re: Required date based on Order Date
              try67 MVP & Adobe Community Professional

              There's no need to do it. The event.rc=false command will reject the new

              value and return the field to its previous value automatically.