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

Acrobat DC dropdown validation script not running

New Here ,
Dec 10, 2023 Dec 10, 2023

 

I have two dropdown fields "BusServiceType" and "D1Period1" in an Acrobat DC form.

I am trying to write a validation script to check "D1Period1" when "BusServiceType" equals a certain value.

The script is added to the Custom Keystroke Script property of both fields.

A simple "app.alert()" test works, proving JS can run.

But change detection scripts on the field value itself do not function.

Here is pseudocode for what I have tried:

 

 

Copy code

if(this.value == "TargetValue") { // Validate }
 

Steps taken:

  • Confirmed field names match script
  • Permissions set properly for scripts
  • Tried on multiple documents
  • Simplified logic greatly

No errors show in console. The script just seems to not run on value change.

Any ideas what could cause this or how I can troubleshoot further? Is there a limitation in Acrobat around custom field scripting?

Please let me know if submitting this on the forums could help escalate to Adobe! I'm happy to provide any other details.

Let me know if you need any changes or have additional details to include. Providing code samples and debugging steps done will help them diagnose potential causes.

TOPICS
JavaScript , Modern Acrobat , PDF , PDF forms
677
Translate
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 ,
Dec 11, 2023 Dec 11, 2023
LATEST

Use the validation property of the fields.

Translate
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 ,
Dec 10, 2023 Dec 10, 2023

I am trying to validate the selections in two dropdown fields, "BusServiceType" and "D1Period1" in an Acrobat DC form I created.

My goal is to show an error message if "D1Period1" does not equal a certain value when "BusServiceType" is set to "Night Bus Service".

I added the following JavaScript code to the Custom Keystroke Script properties of both fields:

if(this.value === "Night Bus Service" && this.getField("D1Period1").value !== "Night Time") { app.alert("Please select Night Time"); }

 

I have also tried various simplified versions:

app.alert("Test");

 

But the change validation code does not ever run when selecting values in the fields.

The test alert works fine, so JavaScript in general is enabled and working.

What could cause the field value validation code to not function?

Is there something special needed to detect form field changes via JavaScript in Acrobat DC?

I have tried across multiple documents and reader/editor users. Permissions set properly.

Please advise how to properly create dropdown value validation scripts.

 

[moderator: merged this thread with similar thread from the same user]

Translate
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 ,
Dec 11, 2023 Dec 11, 2023

Your script is close, try this:

 

if(this.getField("BusServiceType").valueAsString === "Night Bus Service" && event.value !== "Night Time") { 
app.alert("Please select Night Time"); }

 

Use script in 'Validate' tab.

Translate
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