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

Popup Box JavaScript Edit Font Size and Color

Explorer ,
Apr 09, 2025 Apr 09, 2025

Hello. I have an On Blur action for a text box that if anyone typs in the number "5012" it prompts a pop-up box that gives a message. I want to be able to change the font size and color. How can this be done. Below is my script:

 

var fieldValue = this.getField("Text1").value;

if (fieldValue == "5012") {app.alert("***Message to Person***");
}

TOPICS
How to , JavaScript , PDF , PDF forms
191
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
2 ACCEPTED SOLUTIONS
Community Expert ,
Apr 09, 2025 Apr 09, 2025

First, put this action in the "Custom Validation" script for the "Text1" field. 

Next, modify it to use the field event properties. Like this.

if(event.value = "5012"){
   event.target.textColor = color.blue;
   event.target.textSize = 14;
}
else{
   event.target.textColor = color.black;
   event.target.textSize = 12;
}

 

 

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

View solution in original post

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 ,
Apr 09, 2025 Apr 09, 2025

Can't be done. There are few options for the alert box. Text color and size are not include. 

You do have more options with a custom dialog. But the only color options is red or black. And the sizes are on the order of Big, Medium, and small. 

 

 

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

View solution in original post

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 ,
Apr 09, 2025 Apr 09, 2025

First, put this action in the "Custom Validation" script for the "Text1" field. 

Next, modify it to use the field event properties. Like this.

if(event.value = "5012"){
   event.target.textColor = color.blue;
   event.target.textSize = 14;
}
else{
   event.target.textColor = color.black;
   event.target.textSize = 12;
}

 

 

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

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
Explorer ,
Apr 09, 2025 Apr 09, 2025

@Thom Parker Sorry, I just realized my question was not asked very good. I want to be able to chage the color and size of the text within the pop-up 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 Expert ,
Apr 09, 2025 Apr 09, 2025

Can't be done. There are few options for the alert box. Text color and size are not include. 

You do have more options with a custom dialog. But the only color options is red or black. And the sizes are on the order of Big, Medium, and small. 

 

 

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

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
Explorer ,
Apr 10, 2025 Apr 10, 2025

@Thom Parker how do you do the customer dialog?

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
Explorer ,
Apr 10, 2025 Apr 10, 2025
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 ,
Apr 10, 2025 Apr 10, 2025
LATEST

Here's the entry for custom dialogs in the Acrobat JavaScirpt Reference:

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#execdialog

 

Custom dialogs are complex by nature. Here's a WYSWYG tool that makes creating dialog code easier:

https://www.pdfscripting.com/public/ACRODIALOGS-OVERVIEW.cfm

 

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

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