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

Validating Fields in JavaScript

Community Beginner ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

I was going to try and send my PDF file to look at and see what I am doing wrong, but it won't let me.

I have 1 4-page PDF form with several fields and there are 18 required fields on this 4-page form that must be filled out. Step 1 is just a text label that said, "Fill out form". On the last page at the bottom are 3 buttons. The "Step 2" button is visible and said, "Step 2 - Review your answers, then click here to submit form". This button has the following Actions:

Action1.PNG

 The first 2 Show/Hide a fields hides the Step 3 and Step 4 button. Then run the following javascript code

 

if (oField.valueAsString == oField.defaultValue) {
   oField.strokeColor = color.red;
   emptyFields.push(oField.name);

    bProcess = false;
}
else oField.strokeColor = color.transparent;

 

After the javascript code is ran, another Show/Hide for the "Step 3" button.

The "Step 2 button doesn't seem to execute the javascript code.

 

I was trying to follow this article. Either I missed something or of course not doing it right.

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

 

Any help or suggestions would be most appreciated.

 

Thank you,

Randy Duly

 
 
TOPICS
Acrobat SDK and JavaScript

Views

542

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

correct answers 1 Correct answer

Community Expert , Sep 10, 2020 Sep 10, 2020

Correct.

Votes

Translate

Translate
Community Expert ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

You need to do it all in a script, since the other commands will execute no matter what, and you can't control the order in which it will happen (it doesn't have to be the order in which you added them).

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 Beginner ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

So then I would have to put all of my Show/Hide fields in the JavaScript too.

Using the screenshot below to "Hide" "Step 4 - Finish" button.

showhidefield.PNG

 

The code would be:

getField("Step 4 - Finish").display = display.hidden;

 

Correct?

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 ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

Correct.

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 Beginner ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

LATEST

Thank you. Are there any good books, tutorials or YouTube videos out there for us novice users.

I find that this JavaScript API reference manual is not very helpful. Too technical for novice.

Acrobat DC JavaScript API Reference 

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