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

Drop down selection validation

Community Beginner ,
Sep 21, 2018 Sep 21, 2018

Copy link to clipboard

Copied

We are using a pdf as a training document to test users on a web based process.

We want to confirm that users have selected the correct option in the drop down field and if not show a validation to advise them to select to correct response.

We need a custom javascript that reads the "Workflow" field and validates that the response selected is "Level 1 Rebuttal"

Can anyone assist?

The code we have tried is

optionObject.selected

var x=document.getElementById("Level 1 Rebuttal").selected;

optionObject.selected=true/false

We have tried it as an Action on the  drop down field itself as well as the "review form" button on the pdf and neither work if the selection has been changed but is wrong. it only performs the validation if the selection has not changed.

TOPICS
Acrobat SDK and JavaScript

Views

760

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 21, 2018 Sep 21, 2018

Copy link to clipboard

Copied

The JavaScript you've shown is for HTML, not PDF. So are the users selecting a dropdown on a PDF or on an HTML page?

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 23, 2018 Sep 23, 2018

Copy link to clipboard

Copied

We are using a .PDF

We found this script in our search online and it's obvious that we are newbs.

Any help is appreciated!

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 23, 2018 Sep 23, 2018

Copy link to clipboard

Copied

Here are a couple of articles that discuss Acrobat JavaScript ist/dropdown programming.

https://acrobatusers.com/tutorials/list_and_combo_in_lc

https://acrobatusers.com/tutorials/change_another_field

And you'll find tons of info and samples here:

https://www.pdfscripting.com/public/List-Field-Usage-and-Handling.cfm

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 23, 2018 Sep 23, 2018

Copy link to clipboard

Copied

Thanks so much! I took a peek and most of them are scripts to what appearto systemically change the drop-down selection. This form is being used as a "test" and we want the user to be prompted if they missed something.

If the correct answer isn't selected in the drown down when they check their form we would like a notification (validation?) to pop up asking them to check the selection in the drop down. We want the user to select the right answer. We do not want to automatically change their response.

Did I miss something in those links? We can definitely use them in the future but for this issue we need a pop up based on the selection in the drop down and we want the selection to be made by the user.

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 23, 2018 Sep 23, 2018

Copy link to clipboard

Copied

The idea with these articles is to get you familiar with the Acrobat scripting SDK, specifically the types of operations that are possible with dropdowns, and the events that are associated with them. Both are important for scripting a PDF form and you won't be able to do this effectively if you don't have a basic understanding of how lists work in a PDF.

Validation is a broad topic. There are many different ways to implement validation based on the purpose and form usage. You've stated that this is a test document and a "Correct/Incorrect" indication to be given to the user.  It seems this is less of a validation task and more of a test correction script.  To find the best solution we need to know a couple of more things

1. When does the validation happen, immediately when the user selects from the drop down? or after the form is completed?

     - If the validation happens immediately, Should the user be blocked from entering an incorrect value?

2. Are the correct answers the same all the time? Will they need to be updated or changed occasionally.

3. Will the answers be baked into the form or should they exist outside the form, for example in a spread sheet?

4. Should incorrect fields be colored differently?

Here is an example validation script. It must be placed in the Custom script section of the Validation Tab on the DropDown properties dialog.

if(event.rc = (event.value == "Level 1 Rebuttal"))

   app.alert("Incorrect Value");

This script will execute when the dropdown value is "Committed". Normally this happens when user clicks or tabs to another field. If you want it to happen when the selection is made, then the "Commit Selection Immediately" option must be selected on the field properties.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 23, 2018 Sep 23, 2018

Copy link to clipboard

Copied

Thanks Thom- we can probably work with that.

We do have a button "review form" that when clicked checks for blank fields and using validation (and another pirated script) pops up a message to the user that rwmibds then to fill in all the fields. The script to check for the correct answer in the drop down doesn't work and it says they are correct even if the choice is wrong, as long as it isn't blank.

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 23, 2018 Sep 23, 2018

Copy link to clipboard

Copied

LATEST

This is why it is important to know a bit about how lists work in a PDF. The comparison value has to exactly match the export value of the selected list item. So is the export value specified? If so then that is that value that is used in the comparison.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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