Skip to main content
Known Participant
April 9, 2025
Answered

Popup Box JavaScript Edit Font Size and Color

  • April 9, 2025
  • 1 reply
  • 940 views

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

Correct answer Thom Parker

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. 

 

 

1 reply

Thom Parker
Community Expert
Community Expert
April 9, 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 PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
April 9, 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.

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
April 9, 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 PDFScriptingUse the Acrobat JavaScript Reference early and often