Skip to main content
Participant
June 20, 2016
Answered

getField("xxxx").value returns an incorrect value from a dropdown list control, if the value "yes" is selected, the getfield("xxx").value returns "No", and vice versa. This seems to be a bug with Acrobat DC Pro....

  • June 20, 2016
  • 4 replies
  • 1466 views

A simple PDF form with multiple fields,  a validation java script to set required fields based on a value selected in a dropdown.

getField("xxxx").value returns an incorrect value from a dropdown list control, if the value "yes" is selected, the getfield("xxx").value returns "No", and vice versa. This seems to be a bug with Acrobat DC Pro....

Had to do reverse logic to get this to work, however on data extract, incorrect data value is exported

var Name = this.getField("Customer_LandLordDetails_Name");

var Street = this.getField("Customer_LandLordDetails_Street");

var Suburb = this.getField("Customer_LandLordDetails_Suburb");

var City = this.getField("Customer_LandLordDetails_City");

var Province = this.getField("Customer_LandLordDetails_Province");

var Country = this.getField("Customer_LandLordDetails_Country");

var PostalCode = this.getField("Customer_LandLordDetails_PostalCode")

var ContactName = this.getField("Customer_LandLordDetails_ContactName");

var Telephone = this.getField("Customer_LandLordDetails_Telephone");

var Email = this.getField("Customer_LandLordDetails_Email");

var Owned = this.getField("Customer_RegisteredAddress_Owned");

if (Owned.value != "Owned"){

console.println("Value = Owned " + Owned.value);

Name.required = false;

Street.required = false;

Suburb.required = false;

City.required = false;

Province.required = false;

Country.required = false;

PostalCode.required = false;

ContactName.required = false;

Telephone.required = false;

Email.required = false;

} else {

console.println("Value != Owned " + Owned.value)

Name.required = true;

Street.required = true;

Suburb.required = true;

City.required = true;

Province.required = true;

Country.required = true;

PostalCode.required = true;

ContactName.required = true;

Telephone.required = true;

Email.required = true;

}

This topic has been closed for replies.
Correct answer try67

To access the new value of a drop-down field in its own validation script you must not use getField("...").value, but event.value.

4 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 20, 2016

To access the new value of a drop-down field in its own validation script you must not use getField("...").value, but event.value.

Participant
June 20, 2016

Thanks Try67. that seemed to have worked... and changing the comparison form = to ==

try67
Community Expert
Community Expert
June 20, 2016

Yes, because "=" is not a comparison operator at all, it's the assignment operator...