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

Validation scripts

Participant ,
Jan 06, 2023 Jan 06, 2023

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
873
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
1 ACCEPTED SOLUTION
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-propertie...

 

 

 

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

View solution in original post

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

What script does you use?

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

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)

 

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 ,
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-propertie...

 

 

 

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

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

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