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

Validation scripts

Participant ,
Jan 06, 2023 Jan 06, 2023

Copy link to clipboard

Copied

My understanding is that custom validation scripts only run when a field is changed.

 

I am writing a script to validate a date. The script runs only when the field changes (as expected). It is working fine except that it seems to get the value of the field BEFORE the change, not after, and that doesn't do me much good.

 

Obviously I'm missing something. Any help would be appreciated.

 

Jack

 

TOPICS
PDF forms

Views

465

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 , Jan 06, 2023 Jan 06, 2023

The value of the field does not change until after the validation script has been run. So, inside the validation script you cannot use "getField" to get the value of the field on which the validation script is attached. 

Instead, everything about the field that is changing is in the "event" object. 

For example, the newly entered value is in "event.value"

Here's the reference entery:

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#event-properties

 

 

 

Votes

Translate

Translate
Community Expert ,
Jan 06, 2023 Jan 06, 2023

Copy link to clipboard

Copied

What script does you use?

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
Participant ,
Jan 06, 2023 Jan 06, 2023

Copy link to clipboard

Copied

f1=getField("Date Business Started - Month")
f2=getField("Date Business Started - Day")
f3=getField("Date Business Started - Year")
day=f2.value
app.alert("Day is: "+day)

 

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 ,
Jan 06, 2023 Jan 06, 2023

Copy link to clipboard

Copied

The value of the field does not change until after the validation script has been run. So, inside the validation script you cannot use "getField" to get the value of the field on which the validation script is attached. 

Instead, everything about the field that is changing is in the "event" object. 

For example, the newly entered value is in "event.value"

Here's the reference entery:

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#event-propertie...

 

 

 

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
Participant ,
Jan 06, 2023 Jan 06, 2023

Copy link to clipboard

Copied

LATEST

Yes, that makes sense, and it works. I will have to change my approach a bit, but that's a minor problem.

 

Thank you for your assistance.

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