• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Date Autofill when Submitted

New Here ,
Jul 24, 2020 Jul 24, 2020

Copy link to clipboard

Copied

I have a date field that I want to be autofilled with the current date when the form is submitted.  How is that done?

 

I would also like to reset the entire form when the form is submitted.  How is that done?

TOPICS
PDF forms

Views

1.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jul 24, 2020 Jul 24, 2020

Copy link to clipboard

Copied

Hi there

 

We are sorry for the trouble. As described you want to autofill the date whrn the form is submitted

 

Please take a look at the similar discussions below and see if that works for you.

 

  1. https://answers.acrobatusers.com/auto-fill-date-q191015.aspx
  2. https://community.adobe.com/t5/acrobat/auto-fill-today-s-date-into-a-pdf-form/td-p/6067962?page=1

 

Hope it will help

 

Regards

Amal

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 24, 2020 Jul 24, 2020

Copy link to clipboard

Copied

What trouble are you sorry for?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 26, 2020 Jul 26, 2020

Copy link to clipboard

Copied

No trouble.  I am creating an order form that will be accessed by customers through my company's website and I have created the form but have 4 items that I need help with.  I have very little experience with JavaScript (JS) but have figured out how to do a few things.  The items I need help with are:

 

  1. The order form will be submitted once it is completed and I would like the order date to be autofilled when the form is submitted (not when it is opened).  It is important that the order date matches when the order form is submitted.
  2. There is a delivery date that has to be a minimum of 14 days from the order date and no more than 60 days from the order date.  The delivery date is filled in by the customer.  I think this would be a JS inserted into the validation tab but I do not know how to write it.
  3. The order form has the option of  placing 6 orders and I would like to autfill the order number per order but only if it is completed by the customer.  For example if for some reason the first order (1 of 6) is not filled in but order 2 - 4 are completed and orders 5 & 6 are left blank then an order number would be autofilled for order 2 - 4 but would be left blank for 1, 5 & 6.
  4. Once the order form is submitted then the entire form is reset to blank fields or to the default seeting for the field.

 

I appreciate your help.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 27, 2020 Jul 27, 2020

Copy link to clipboard

Copied

My reply was to Amal, not to you. I simply don't like this boilerplate "We're sorry for the trouble" text, as it's meaningless and often not relevant to the situation, like in your case...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 28, 2020 Jul 28, 2020

Copy link to clipboard

Copied

I am using this script to set the order date when the file is opening but what/how do I revise this script to set the date when the form is Submitted?

 

this.addScript("init", "var f = this.getField(\"Today\"); if (f.value==\"\") f.value = new Date();");

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 28, 2020 Jul 28, 2020

Copy link to clipboard

Copied

That script does not set the date, it adds a script that sets the date... You only need to run it once.

To set the date when the file is submitted you will need to add the same code to your Submit button.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 28, 2020 Jul 28, 2020

Copy link to clipboard

Copied

I am trying validate that the delivery date is >= (order date +14 days) and I wrote the following script but nothing seems to be happening:

 

("Delivery Date")>=("Order Date")+14

 

I am sure there is but is there a better way to write this?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 28, 2020 Jul 28, 2020

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 28, 2020 Jul 28, 2020

Copy link to clipboard

Copied

Thanks.  One thing that I have noticed about us humans is that if we can complicate something we will.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 28, 2020 Jul 28, 2020

Copy link to clipboard

Copied

I don't think it's an over-complication. What you tried to do is an over-simplification of a complex subject.

 

Just so you know, other programming languages have a much more complex Date object than JavaScript, including complete separate implementations for the Gregorian calendar, the Julian calendar, the Muslim calendar, the Jewish calendar, the Japanese calendar, etc.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 30, 2020 Jul 30, 2020

Copy link to clipboard

Copied

Thank you for the articles.  They helped me figure out the script below.  I inserted the script to set the "Order Date" into the SUBMIT button as you suggested above and it works perfectly.  After this date script I added the following script to confirm the injection date is 14 or more days past the "Order Date" but of course it does not work.  I chose to add this script to the SUBMIT button (but after the Orer Date script) because the Order Date is not added until submitting but should it be added to the Validation tab for the "Inj Dt Dog 6" field?

 

The customer adds the injection date and it is formatted the same as the order date (mm/dd/yyyy).

 

var strStart = this.getField("Order Date").value;
var strEnd = this.getField("Inj Dt Dog 6").value;
if(strStart.length && strEnd.length)
{
var dateStart = util.scand("mm/dd/yyyy",strStart);
var dateEnd = util.scand("mm/dd/yyyy",strEnd);
var diff = dateEnd.getTime() - dateStart.getTime();
var oneDay = 24 * 60 * 60 * 1000;
var days = Math.floor(diff/oneDay) >= 14;
}
else
app.alert("Injection Date for Dog 6 needs to be 14 days past Order Date");

 

Thanks for your input and help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 07, 2020 Aug 07, 2020

Copy link to clipboard

Copied

try67

 

I added the following script to the SUBMIT button butand removed all the script on the "Order Date" field but the when the file is opened the Order Date field updates to the current date instead of waiting for the SUBMIT button to be selected.  Why is that?

 

this.addScript("init", "var f = this.getField(\"Order Date\"); if (f.value==\"\") f.value = new Date();");

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 07, 2020 Aug 07, 2020

Copy link to clipboard

Copied

Again, this code does NOT set the field's value. It adds a script to the file that does.

To set the field's value directly use this:

var f = this.getField("Order Date"); if (f.value=="") f.value = new Date();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 07, 2020 Aug 07, 2020

Copy link to clipboard

Copied

Thanks for your help but I must be doing something wrong.  I deleted the old script and added the script you suggested to the SUBMIT button so that the current date would not be added to the Order Date field until the SUBMIT button was selected but when I reopened the file the Order Date field immediately updated to the current date.  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 07, 2020 Aug 07, 2020

Copy link to clipboard

Copied

That's because you already added that code as a doc-level script... Go to Tools - JavaScript - Document JavaScripts and delete the "init" script from there.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 07, 2020 Aug 07, 2020

Copy link to clipboard

Copied

Thank you.  

 

For the other items that I am trying to create (listed below) can you recommend anyone that could help me with the JavScript?

 

  1. There is a delivery date that has to be a minimum of 14 days from the order date and no more than 60 days from the order date.  The delivery date is filled in by the customer.  I think this would be a JS inserted into the validation tab but I do not know how to write it.
  2. The order form has the option of  placing 6 orders and I would like to autfill the order number per order but only if it is completed by the customer.  For example if for some reason the first order (1 of 6) is not filled in but order 2 - 4 are completed and orders 5 & 6 are left blank then an order number would be autofilled for order 2 - 4 but would be left blank for 1, 5 & 6.
  3. Once the order form is submitted then the entire form is reset to blank fields or to the default setting for the field.

 

Thanks for your help and have a great weekend!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 07, 2020 Aug 07, 2020

Copy link to clipboard

Copied

LATEST

I can set it all up for you, for a small fee. You can contact me directly via [try6767 at gmail.com].

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines