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

No message displayed on using app.alert

Community Beginner ,
Jan 11, 2024 Jan 11, 2024

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.

 

 

TOPICS
Acrobat SDK and JavaScript
3.6K
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 11, 2024 Jan 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?

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 Beginner ,
Jan 11, 2024 Jan 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_nZi7...
Origilal PDF Formular

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 11, 2024 Jan 11, 2024

- I don't see the code anywhere. Under what exact field did you place it?

- You need to become familiarized with the JS Console if you're going to write scripts for PDF files.

See: https://acrobatusers.com/tutorials/javascript_console

 

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 Beginner ,
Jan 11, 2024 Jan 11, 2024

I placed the code on the MINI-TENNIS check Box Acobat action whith the trigger Check Box active.

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 Beginner ,
Jan 11, 2024 Jan 11, 2024

In Acrobat I  copied and pastedid the code and  Add (ajouter in French) and it said Execute a scrip Javascript.
That's all. 

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 11, 2024 Jan 11, 2024

There's no field with that name in the file you sent, and no scripts whatsoever.

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 Beginner ,
Jan 11, 2024 Jan 11, 2024

The field is MINI-TENNIS which is a check box of the text Cours Mini Tennis (de 5 à 7 ans) in the formular..

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 Beginner ,
Jan 11, 2024 Jan 11, 2024

Concerning the script Please tell me in Acrobat when you add a script if Acrobat shouls display the scrip or like for my exemple it just said  Exécuter un script Javascript  on the action Acrobat box (

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 Beginner ,
Jan 11, 2024 Jan 11, 2024

I will be absent until 5PM I have to leave
Thank you for your help.
I have to reasd the console tutoriel.
Thank you very much
See you later I am going to an appointment to my doctor.

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 11, 2024 Jan 11, 2024

The text "Cours Mini Tennis" doesn't appear in the file. I'm not going to spend any more time on this.

Share the correct file if you want any help.

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 Beginner ,
Jan 11, 2024 Jan 11, 2024

Sorry
Tis is the correct file

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 Beginner ,
Jan 11, 2024 Jan 11, 2024
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 11, 2024 Jan 11, 2024

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

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 Beginner ,
Jan 11, 2024 Jan 11, 2024

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.

 

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 11, 2024 Jan 11, 2024

Change this line:

if (caseMiniTennis && caseMiniTennis.isBoxChecked(0)) {

To:

if (event.target.value!="Off") {

 

Then use the JS Console to track down the many errors in your code and solve them one at a time.

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 Beginner ,
Jan 11, 2024 Jan 11, 2024

Thank you but as I said I am not abble to open the Js console on my mac.
I tyme the command * J but it doesn't work and I don't find any menu for that.
Sorry but I am Beginner

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 Beginner ,
Jan 11, 2024 Jan 11, 2024

command + J

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 Beginner ,
Jan 13, 2024 Jan 13, 2024
LATEST

I finally progress and I  am able to display using the function alert.
In addition I have seen how to use the windows console, easy and usefull tool for debbuging.
Thank you for your help.

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