Highlighted

Date Autofill when Submitted

New Here ,
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

92

Likes

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

Date Autofill when Submitted

New Here ,
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

93

Likes

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
Jul 24, 2020 0
Adobe Employee ,
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

Likes

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
Reply
Loading...
Jul 24, 2020 0
Most Valuable Participant ,
Jul 24, 2020

Copy link to clipboard

Copied

What trouble are you sorry for?

Likes

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
Reply
Loading...
Jul 24, 2020 0
New Here ,
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.

 

 

Likes

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
Reply
Loading...
Jul 26, 2020 0
Most Valuable Participant ,
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...

Likes

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
Reply
Loading...
Jul 27, 2020 0
New Here ,
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();");

Likes

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
Reply
Loading...
Jul 28, 2020 0
Most Valuable Participant ,
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.

Likes

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
Reply
Loading...
Jul 28, 2020 0
New Here ,
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?

Likes

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
Reply
Loading...
Jul 28, 2020 0
Most Valuable Participant ,
Jul 28, 2020

Copy link to clipboard

Copied

Likes

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
Reply
Loading...
Jul 28, 2020 0
New Here ,
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.

Likes

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
Reply
Loading...
Jul 28, 2020 0
Most Valuable Participant ,
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.

Likes

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
Reply
Loading...
Jul 28, 2020 0
New Here ,
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!

Likes

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
Reply
Loading...
Jul 30, 2020 0
New Here ,
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();");

Likes

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
Reply
Loading...
Aug 07, 2020 0
Most Valuable Participant ,
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();

Likes

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
Reply
Loading...
Aug 07, 2020 0
New Here ,
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.  

Likes

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
Reply
Loading...
Aug 07, 2020 0
Most Valuable Participant ,
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.

Likes

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
Reply
Loading...
Aug 07, 2020 0
New Here ,
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!

Likes

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
Reply
Loading...
Aug 07, 2020 0
try67 LATEST
Most Valuable Participant ,
Aug 07, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Aug 07, 2020 0