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

Alert box for a form filled under 1000 characters

New Here ,
May 23, 2020 May 23, 2020

Copy link to clipboard

Copied

Hello everybody,

I am creating a form with a text field named as "MOTIVATION". I want a warning to appear if the number of characters (including letters, numbers and spaces) is less than 1000 characters when pressing save or close buttons. The warning will be like;

 

THE NUMBER OF CHARACTERS IS LESS THAN 1000.

DO YOU WANT TO CONTINUE?

                                                                                          YES / NO 

 

Any help will be appreciated. 

Regards

Vahap

 

TOPICS
Acrobat SDK and JavaScript

Views

367

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
community guidelines

correct answers 1 Correct answer

Community Expert , May 23, 2020 May 23, 2020

You can't stop a PDF from being saved or closed. Maybe you should popup a warning when the user finishes typing in the field. Use a validation script for this.

 

Or you could have a big red text field displayed at the top or bottom of the form that doesn't go away until the field is filled correctly.

 

In any case, this code will display an alert for a field that has less than 1000 characters

 

if(this.getField("Text1").valueAsString.length < 1000)

   app.alert("Less than 1000 characters");

 

Yo

...

Votes

Translate

Translate
Community Expert ,
May 23, 2020 May 23, 2020

Copy link to clipboard

Copied

You can't stop a PDF from being saved or closed. Maybe you should popup a warning when the user finishes typing in the field. Use a validation script for this.

 

Or you could have a big red text field displayed at the top or bottom of the form that doesn't go away until the field is filled correctly.

 

In any case, this code will display an alert for a field that has less than 1000 characters

 

if(this.getField("Text1").valueAsString.length < 1000)

   app.alert("Less than 1000 characters");

 

You can find out more about alert box scripts here:

https://acrobatusers.com/tutorials/popup_windows_part1/

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
New Here ,
May 25, 2020 May 25, 2020

Copy link to clipboard

Copied

LATEST

Hi Thom,

thanks a lot for your help. 

Regards

Vahap

Votes

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
community guidelines