Javascript

New Here ,
Nov 08, 2019

Copy link to clipboard

Copied

Hello,

 

i refer to the following link: JavaScript™ for Acrobat® API Reference. How do you correctly address text fields and selection fields in Javacript? Is there a short form in Javascript regarding mandatory fields?

 

Example code that does not work:

 

var empty = "";

if(this.getField("Example") == empty)
{
app.alert("Error");
}
 

 

This is just a test.

 

How should the Javascript code begin in Adobe?

 

Best regards

 

Christian Huml

TOPICS
Acrobat SDK and JavaScript, PDF forms, Windows

Views

44

Likes

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

Javascript

New Here ,
Nov 08, 2019

Copy link to clipboard

Copied

Hello,

 

i refer to the following link: JavaScript™ for Acrobat® API Reference. How do you correctly address text fields and selection fields in Javacript? Is there a short form in Javascript regarding mandatory fields?

 

Example code that does not work:

 

var empty = "";

if(this.getField("Example") == empty)
{
app.alert("Error");
}
 

 

This is just a test.

 

How should the Javascript code begin in Adobe?

 

Best regards

 

Christian Huml

TOPICS
Acrobat SDK and JavaScript, PDF forms, Windows

Views

45

Likes

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
Nov 08, 2019 0
Most Valuable Participant ,
Nov 08, 2019

Copy link to clipboard

Copied

I don't see an immediate problem with your code. Of course, writing the code is only half the story; you also have to decide which event to attach it to.  What happens when you try to use it. and what does it say in the console?

Likes

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
Reply
Loading...
Nov 08, 2019 0
Adobe Community Professional ,
Nov 08, 2019

Copy link to clipboard

Copied

Try this:

var empty = "";
if(this.getField("Example").value == empty)
{
app.alert("Error");
}

Likes

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
Reply
Loading...
Nov 08, 2019 0