Skip to main content
Participating Frequently
January 11, 2024
Question

No message displayed on using app.alert

  • January 11, 2024
  • 1 reply
  • 3503 views

Hello,
I have a problem displaying a script in Acrobat DC.
I've created a script for a form field.
I use the javscript instruction "app.alert" to display the message corresponding to the result of a validation check of the data entered, but the message is not displayed.
Can you please tell me why the message is not displayed?
Here's the script:
// Replace "MINI-TENNIS" and "DATE OF BIRTH" with the actual IDs of your fields in the form
var caseMiniTennis = this.getField("MINI-TENNIS");
var caseBirthDate = this.getField("BIRTHDATE");

// Check if the MINI-TENNIS box is ticked
if (caseMiniTennis && caseMiniTennis.isBoxChecked(0)) {
// Get the date of birth entered
var dateBirth = champDateBirth.value;

// Check whether the date of birth corresponds to a child aged 5 to 7
var yearYear = new Date().getFullYear();
var debutSaison = new Date(anneeEnCours - 7, 8, 1); // Start date for a 7-year-old child
var finSaison = new Date(anneeEnCours - 5, 7, 31); // End date for a 5-year-old child

var dateBirthObj = new Date(dateBirth);

// Check if date of birth is in the range 5 to 7 years old
if (debutSaison <= dateNaissanceObj && dateNaissanceObj <= finSaison) {
app.alert("The date of birth corresponds to a child aged 5 to 7: " + dateBirth);
} else {
app.alert("The date of birth does not correspond to a child aged 5 to 7: " + dateBirth);
}
} else {
app.alert("The MINI-TENNIS box is not checked.");
}

 

Thank you.

 

 

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
January 11, 2024

- Where did you place the code? What triggers it?

- Are there any error messages in the JS Console when you run it?

- Can you share the actual file with us?

Participating Frequently
January 11, 2024

- I placed the script on acrobat action
_ I don't know how to heck on console. In addition I use the app;alert instruction not the console instruction
- I attached all the files

Empty Web formular : https://eu1.documents.adobe.com/public/esignWidget?wid=CBFCIBAA3AAABLblqZhDWdj4H_CN7fBupSwRIbUd_nZi7Ep7K8kXuoSvexBp0XEK4pBd9vIRGBrSeUjnZFzg*
Origilal PDF Formular

Participating Frequently
January 11, 2024

There's no code, but when I add it the alert appears. However, your logic behind it is incorrect.


Does it mean that when adding the JS code it has been checked and it is the reason that it doesn't apper  on the action acrobat box?
I have read the windows console and I modified the Acrobat preferences but I don't know how to start with.