5 Replies Latest reply: Dec 21, 2011 5:31 AM by SusanSherman RSS

    Insert Auto Date field in form

    SusanSherman Community Member

      This seems like such a simple task, I cannot believe I am posting here for help! 

       

      I would like my form to automatically insert the current date when opened, but cannot figure out how to make this happen.  The only date settings I can find are only to format the date once the user enters the values.  Can anyone help me?

       

      I am using Adobe Acrobat Pro v 9.4.7 on a Windows XP sp3 OS

       

      Thanks!

       

      Susan

        • 1. Re: Insert Auto Date field in form
          George Johnson CommunityMVP

          The following code will do it:

           

          getField("your_date_field").value = util.printf("mm/dd/yyyy", new Date());

           

           

          But you'll need to place it either in a document-level JavaScript outside of a function definition, or in the initial page's Page Open event.

           

          To create a new document-level JavaScript, select "Advanced > Document Processing > Document JavaScripts...", enter a name for the script (e.g., "init"), click the Add button, delete the function skeleton it gives you by default, and enter the line of code from above. Replace "your_date_field" with the actual name of your date field.

          • 2. Re: Insert Auto Date field in form
            SusanSherman Community Member

            George,

             

            Thanks for your reply.  I did as you indicated and I'm "getting there" but not quite.  Now, my field reads "mm/dd/yyyy" when the document is opened.  How do I get it to actually insert today's date?

             

            Susan

            • 3. Re: Insert Auto Date field in form
              George Johnson CommunityMVP

              Oops! I made a small typo. The correct code is:

               

              getField("your_date_field").value = util.printd("mm/dd/yyyy", new Date());

              • 4. Re: Insert Auto Date field in form
                SusanSherman Community Member

                Thanks George!  That did it.  I am so amazed that Adobe doesn't include the auto date field as a built-in option, but this code is great!

                 

                I appreciate your time!

                 

                Susan

                • 5. Re: Insert Auto Date field in form
                  SusanSherman Community Member

                  George, can you help with a new issue on this? 

                   

                  In this thread (http://forums.adobe.com/thread/940091?tstart=0) you can see that I had issues with the tabbing order.  Daniel's solution worked great, but now I have lost the auto date functionality!  The java script was gone from the document after making the tab order updates in Live Cycle.  No problem, I put it back in (using the corrected string you provided above).  Unfortunately, it isn't working now!

                   

                  Any thoughts on what happened?  Obviously, the tab order is higher on the priority list than the auto date, but I'd really like to have both.

                   

                  Thanks for your additional expertise and time!  I truly appreciate your assistance!

                   

                  Susan