Skip to main content
Known Participant
Apr 9, 2025 6:57 PM UTC
Answered

Popup Box JavaScript Edit Font Size and Color

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***");
}

Thom Parker
Thom ParkerCorrect answer
Community Expert
Apr 9, 2025 10:32 PM UTC

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 PDFScriptingUse the Acrobat JavaScript Reference early and often

6 replies

Thom Parker
Community Expert
Community Expert
Apr 9, 2025 7:31 PM UTC

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;
}

 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
Apr 9, 2025 9:11 PM UTC

@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
Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
Apr 9, 2025 10:32 PM UTC

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. 

 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often