2 Replies Latest reply on Feb 10, 2017 2:49 AM by JR_Boulay

    Problem with autofill date field.

    annj19137603 Level 1

      Hi,

      I am trying to create an autofill date field on an Acrobat form that does not change once calculated, ie. the user opens the form and the date populates automatically, the user saves the form but on subsequent opening, the original date remains.

       

      So far I have successfully created a Javascript in Page Properties Actions to print the date on opening the form but I cannot find a way of prevent further changes.  I have tried various scripts to do this but none worked for me.

       

      I also tried creating a field level calculation which worked fine in so much that it populated the field with the date as required but I couldn't clear the form before saving it for use.  I found a debugging script to enable me to clear the field - great - but after saving and trying to use the form, the field remained blank.  So I'm back to square one.  I don't really mind if the field completes on opening the form or on a mouse click, as long as the date does not change if the form is reopened on another day.

       

      if((typeof DEBUG !='undefined')&&(DEBUG==true))

      {event.value="";}

      else if(event.target.value=="")

      {event.value=util.printd("dd/mm/yy",new Date());}

       

       

      DEBUG=true;

      this.calculateNow();

        • 1. Re: Problem with autofill date field.
          gkaiseril MVP & Adobe Community Professional

          I would test the date to see if it already had a value of not. If not then I would populate the date field.

           

          You will have to make sure the date field is empty when you save the distribution version of the form. I would also use a document level script to fill-in the date field in order to improve the efficiency of the form. Using a calculation field will cause the script to be run each time any field that contributes to a calculation is updated. On a large complex form repeating unnecessary calculations will adversely affect the responsiveness of the form.

          • 2. Re: Problem with autofill date field.
            JR_Boulay Adobe Community Professional

            Hi.

             

             

            Use this JavaScript as a document level script:

             

            var f = this.getField("DATE");
                if(f.value == null || f.value == "") {f.value = util.printd("dd/mm/yyyy", new Date());}