Highlighted

Validating Fields while preventing an email to be sent until all required fields are c

New Here ,
Sep 28, 2020

Copy link to clipboard

Copied

Hi all-

I was hijacking someone else post and since I was probably being impolite, I thought I better move my post over to a new post. I do want to thank all of those who have helped me so far. 

 

If anyone want to look at the original post, here it is: https://community.adobe.com/t5/acrobat/validating-fields-in-javascript-while-preventing-an-email-to-... 

 

I am posting all Javascript in the PDF and I attach the pages of the PDF file to give you an idea of what I am trying to accomplish. I hope I have enough detail in here.

 

Script to apply "Today's Date". It works.

//<AcroForm>
//<ACRO_source>Today's Date:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:Today's Date:Calculate ***********/
dateToday();
//</ACRO_script>
//</AcroForm>

 Button 2 script

//Validation of the fields;
var emptyFileds - new Array(); //array to hold imcomplete field names;
var oField; // variable to hold field object being tested;
var bProcess = true; // assume all fields completeed;
this.getField("Step 3 - Email will open click the Send email button.").display = display.hidden;
this.getField("Step 4 - Finish").display = display.hidden;
if (oField.valueAsString == oField.defaultValue) {
   oField.strokeColor = color.red;
   emptyFields.push(oField.name);
   bProcess = false;
}
else { oField.strokeColor = color.transparent;
	this.getField("Step 2 - Review your answers then click here to submit form").display = display.visible;
}

Button 3 - No script, just a "Submit a form" and "Show/hide a field action"

submitaform1.PNG

 

ShowHideFieldForStep3.PNG

 

 

 

 

 Step 4 - No script - just a "Reset a form", Execute a menu item - View > Page Navigation > First Page", (2) "Show/Hide a field" actions.

Step4ActionMenu1.PNG

 

 

 I reset all fields

Step4ResetForm1.PNG

 

 

Then go to First Page of a 4 page PDF file

Now Hide Step 3 button

Step4FirstHideShowField1.PNG

 

 

Hide Step 4 button.

Step4SecondShowHideField1.PNG

End of processing.

 

TOPICS
PDF forms

Views

119

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

Validating Fields while preventing an email to be sent until all required fields are c

New Here ,
Sep 28, 2020

Copy link to clipboard

Copied

Hi all-

I was hijacking someone else post and since I was probably being impolite, I thought I better move my post over to a new post. I do want to thank all of those who have helped me so far. 

 

If anyone want to look at the original post, here it is: https://community.adobe.com/t5/acrobat/validating-fields-in-javascript-while-preventing-an-email-to-... 

 

I am posting all Javascript in the PDF and I attach the pages of the PDF file to give you an idea of what I am trying to accomplish. I hope I have enough detail in here.

 

Script to apply "Today's Date". It works.

//<AcroForm>
//<ACRO_source>Today's Date:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:Today's Date:Calculate ***********/
dateToday();
//</ACRO_script>
//</AcroForm>

 Button 2 script

//Validation of the fields;
var emptyFileds - new Array(); //array to hold imcomplete field names;
var oField; // variable to hold field object being tested;
var bProcess = true; // assume all fields completeed;
this.getField("Step 3 - Email will open click the Send email button.").display = display.hidden;
this.getField("Step 4 - Finish").display = display.hidden;
if (oField.valueAsString == oField.defaultValue) {
   oField.strokeColor = color.red;
   emptyFields.push(oField.name);
   bProcess = false;
}
else { oField.strokeColor = color.transparent;
	this.getField("Step 2 - Review your answers then click here to submit form").display = display.visible;
}

Button 3 - No script, just a "Submit a form" and "Show/hide a field action"

submitaform1.PNG

 

ShowHideFieldForStep3.PNG

 

 

 

 

 Step 4 - No script - just a "Reset a form", Execute a menu item - View > Page Navigation > First Page", (2) "Show/Hide a field" actions.

Step4ActionMenu1.PNG

 

 

 I reset all fields

Step4ResetForm1.PNG

 

 

Then go to First Page of a 4 page PDF file

Now Hide Step 3 button

Step4FirstHideShowField1.PNG

 

 

Hide Step 4 button.

Step4SecondShowHideField1.PNG

End of processing.

 

TOPICS
PDF forms

Views

120

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
Sep 28, 2020 0
New Here ,
Sep 28, 2020

Copy link to clipboard

Copied

Here is what the form look like:

Page 1:It is just a text page with instructions for the applicant.

FirstPageOfPDF1.PNG

Page 2: Beginning of Job Application

Step4SecondShowHideField1.PNG

Page 3:

ThirdpageofthePDF1.PNG

Last page 4:

LastpageofthePDF1.PNG

This should give you an idea of what I am trying to accomplish.

Here is the new code since original post:

//Validation of the fields;
var emptyFields = new Array(); //array to hold imcomplete field names;
var oField = ""; // variable to hold field object being tested;
var bProcess = true; // assume all fields completeed;
this.getField("Step 3 - Email box will open up, click the Send email button").display = display.hidden;
this.getField("Step 4 - Finish").display = display.hidden;
if (oField.valueAsString == oField.defaultValue) {
   oField.strokeColor = color.red;
   emptyFields.push(oField.name);
   bProcess = false;
}
else { oField.strokeColor = color.transparent;
	this.getField("Step 2 - Review your answers then click here to submit form").display = display.visible;
}

 

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...
Sep 28, 2020 0
Most Valuable Participant ,
Sep 29, 2020

Copy link to clipboard

Copied

First of all, I moved your question to the Acrobat forum.

 

You posted a lot of information, but it's not clear what your actual question is...

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...
Sep 29, 2020 0
New Here ,
Sep 29, 2020

Copy link to clipboard

Copied

Sorry, first of all I don't know what happened to the title, it is supposed to say, "Validating Fields while preventing an email to be sent until all required fields are complete".

 

As I tried to follow the previous forum thread:

https://community.adobe.com/t5/acrobat/validating-fields-in-javascript-while-preventing-an-email-to-... 

 

I put that code into my "Step 2" button. Got rid of all errors that the debugger showed, but code doesn't do anything. Like I said in previous post, I haven't wrote code since 2008. I am sure I am missing something somewhere. I am not sure what.

 

Any help would be greatly appreciated.

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...
Sep 29, 2020 0
Most Valuable Participant ,
Sep 29, 2020

Copy link to clipboard

Copied

If you want to perform actions conditionally they have to all be done using a script. You can't make other kinds of actions conditional.

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...
Sep 29, 2020 0
New Here ,
Sep 29, 2020

Copy link to clipboard

Copied

If I understand you correctly. All of the buttons has to be written in Javascript. 

So my "Step 3" button in the above example would have to be done in Javascript and the same for the "Step 4" 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...
Sep 29, 2020 0
Most Valuable Participant ,
Sep 29, 2020

Copy link to clipboard

Copied

Correct, including the command to submit the file, which seems to be missing entirely from your description.

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...
Sep 29, 2020 0
New Here ,
Sep 29, 2020

Copy link to clipboard

Copied

I guess I forgot that screenshot.

Step3a.PNG

 

 

 

 

 

 

 

 

 

 

 

 

It should have been before this slide

submitaform1.PNG

 

 

 

 

 

 

 

 

 

 

 

 

Of all of the training videos I watched on YouTube, I don't think any of them mentioned that can't mixed and match different Actions with the Javascript action.

 

To make myself clear and we are talking same language:

You can't do the below example, unless you add all 3 actions in one Javascript, correct?

ExampleActionScreen.PNG

 

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...
Sep 29, 2020 0
Most Valuable Participant ,
Sep 29, 2020

Copy link to clipboard

Copied

You can do it, but all of the non-JS actions will execute no matter what happens in it. If you want to perform a validation then you must do it all in JS. Also, the order of your commands is reversed, assuming you wanted the JS command to perform the validation and then show/hide the fields and then submit the form, and not the other way around.

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...
Sep 29, 2020 0
New Here ,
Sep 29, 2020

Copy link to clipboard

Copied

Yes, you are right, that was bad example.

It should have looked like this. But you would saying that all of these steps would have to be added to the javascript, correct. The "Submit form" and "Show/Hide field" actions added to the "Run a Javascript" action.

ExampleActionScreen.PNG

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...
Sep 29, 2020 0
Most Valuable Participant ,
Sep 29, 2020

Copy link to clipboard

Copied

Correct.

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...
Sep 29, 2020 0
randyd69 LATEST
New Here ,
Sep 29, 2020

Copy link to clipboard

Copied

Thank you for being patience with me. I feel like a novice all over again. I guess I better get busy wriiting some more javascript.

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...
Sep 29, 2020 0