Skip to main content
Inspiring
January 6, 2023
Answered

Validation scripts

  • January 6, 2023
  • 1 reply
  • 1022 views

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

 

This topic has been closed for replies.
Correct answer Thom Parker

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

 

 

 

1 reply

Bernd Alheit
Community Expert
Community Expert
January 6, 2023

What script does you use?

Jack157FAuthor
Inspiring
January 6, 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)

 

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
January 6, 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

 

 

 

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