2 Replies Latest reply on Oct 9, 2014 11:51 AM by Formzet - Zoetermeer

    Date validation between past and future date

    Formzet - Zoetermeer Level 1

      I need to validate a date.

      This date cannot be in the past and cannot be newer then 31122014 (ddmmyyyy).

       

      i just can't get it to work.

      Please help

        • 1. Re: Date validation between past and future date
          try67 MVP & Adobe Community Professional

          You can use this code as the custom validation script of your field:

           

          (function() {
              var d = util.scand("ddmmyyyy", event.value);
              if (d==null) {
                  app.alert("Invalid date string.");
                  event.rc = false;
                  return;
              }
             
              if (d.getTime()<new Date().getTime()) {
                  app.alert("The date cannot be in the past.");
                  event.rc = false;
                  return;
              }
             
              var maxDate = util.scand("ddmmyyyy", "31122014");
              if (d.getTime()>maxDate.getTime()) {
                  app.alert("The date may not be past 31/12/2014.");
                  event.rc = false;
                  return;
              }
             
              event.rc = true;
          
          })();
          
          • 2. Re: Date validation between past and future date
            Formzet - Zoetermeer Level 1

            Thank you.

            You're a life saver