1 Reply Latest reply on Sep 3, 2015 1:07 PM by gkaiseril

    Help with Validating Dates Entered in Separate DD MM YYYY fields

    AngelaAdam Level 1

      Is there a way in Acrobat XI to validate that the entries in three fields (one for DD, one of MM and one for YYYY) when completed make a valid date?

      (For example, someone entering February 30th 2015 (30/02/2015) would get an error message?) Is there any way to handle leap years?




      The three fields are named "Date_DD" "Date_MM" and "Date_YYYY"


      Hopefully I'm not asking for something impossible. The previous version of this form was created in LiveCycle with a date picker, but that's not an option this time around. Hoping somehow there's a workaround in Acrobat.


      Any advice is appreciated.

        • 1. Re: Help with Validating Dates Entered in Separate DD MM YYYY fields
          gkaiseril MVP & Adobe Community Professional

          Date pickers are available but not built-in and are user written. It is also possible to use a single field with the date format and one of the many possible date images or a user created image and the validation will be done by Acrobat/Reader.


          The field in LiveCycle was also a single field with a format of image of "dd/mm/yyyy" and one could type the date string into the field or use the date picker.

          If you insist on the harder way:

          function Scand(cFormat, cDate) {
          // convert date string to date object with validation;
          var oDate = util.scand(cFormat, cDate);
          if(oDate == null) {
          app.alert("Error in converting " + cDate + " with a format of " + cFormat, 1, 0);
          return oDate;
          } // end Scand function;

          function GetField(cName) {
          // get field object with error checking;
          var oField = this.getField(cName);
          if(oField == null) {
          appp.alert("Error accessing field " + cName, 1, 0);
          return oField;
          } // end GetField function;

          // get the values;
          var cFieldMonth = "Date_MM";
          var cFieldDate = "Date_MM";
          var cFieldYear = "Date_YYYY";

          var cMonth = GetField(cFieldMonth).value; // input value for month;
          var cDate = GetField(cFieldDate).value; // input value of date;
          var cYear = GetField(cFieldYear).value; ; //input value or year;
          // strings for conversion;
          var cDateString = cDate + "/" + cMonth + "/" + cYear;
          var cDateFormat = "dd/mm/yyyy";
          if(cMonth !- "" && cDate != "" && cYear != "" ) {
          // test the date if input fields not empty;
          var oTestDate = Scand(cDateFormat, cDateString);
          if(oTestDate == null) app.alert("Invalid date " + cDateString);
          else console.println(oTestDate);