Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
- 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?
Copy link to clipboard
Copied
- 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
Copy link to clipboard
Copied
- 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
Copy link to clipboard
Copied
Copy link to clipboard
Copied
In Acrobat I copied and pastedid the code and Add (ajouter in French) and it said Execute a scrip Javascript.
That's all.
Copy link to clipboard
Copied
There's no field with that name in the file you sent, and no scripts whatsoever.
Copy link to clipboard
Copied
The field is MINI-TENNIS which is a check box of the text Cours Mini Tennis (de 5 à 7 ans) in the formular..
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Empty Web formular : https://eu1.documents.adobe.com/public/esignWidget?wid=CBFCIBAA3AAABLblqZhBwrqVv_yJwCYtzn3MMrUIjIoXA...
Is the User web PDF file
Copy link to clipboard
Copied
There's no code, but when I add it the alert appears. However, your logic behind it is incorrect.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
command + J
Copy link to clipboard
Copied
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.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more