1 Reply Latest reply on Jan 4, 2013 3:48 PM by gkaiseril

    Date Field in Adobe Acrobat X

    ToniChaffin Level 1

      I have a form that users fill in. One of the fields on this form is a date. Through the properties I have set the date format of dd/mm/yyyy. What I was hoping to be able to do next is, get it to auto populate. So when the field onFocus it executes something similar to the now() you can use in MS Access etc.

       

      Is there a way of getting it to add the system date automatically if so, how?

       

      Many thanks in anticipation of a speedy helpful response

       

      Kindest Regards

       

      Toni

        • 1. Re: Date Field in Adobe Acrobat X
          gkaiseril MVP & Adobe Community Professional

          Do you want  the date fields to populate when the form is opened or from a user entry?

           

          You can get the system date object with the script "new Date()". You format the date object with the "util.printd()" method. So if you want to populate a field, "StartDate" when the PDF is opened, you can use a document level script or page open script of:

           

          // get the current date's date object

          var oDate = new Date();

          // set the field value

          this.getField("StartDate").value = util.printd("mm/dd/yyyy", oDate);

           

          Once you have the date object you can increment the date object using the "getDate()" and "setDate()" methods.

           

          var oDate = new Date();

          // set the field value

          this.getField("StartDate").value = util.printd("mm/dd/yyyy", oDate);

          // next day

          oDate.setDate(oDate.getDate() + 1);

          // format and set vlaue

          this.getField("StartDatePlus1").value = util.printd("mm/dd/yyyy", oDate);

          // next day

          oDate.setDate(oDate.getDate() + 1);

          // format and set vlaue

          this.getField("StartDatePlus2").value = util.printd("mm/dd/yyyy", oDate);