Skip to main content
Participant
February 20, 2023
Question

javascript color border

  • February 20, 2023
  • 2 replies
  • 3534 views

hello I am looking for an example of a javascript script for a form on acrobat as soon as the form field contains data I would like the border to be a blue color and as soon as the form field has no data I would like it to be red in color

This topic has been closed for replies.

2 replies

ls_rbls
Community Expert
Community Expert
February 20, 2023

Hi ,

 

This can be accomplished with various scripting methods.

 

In my example below, I decided to use a custom fomat keystroke script.

 

(event.willCommit && (event.value =="")) ? event.target.strokeColor = color.red : event.target.strokeColor = color.blue;

 

Thom Parker
Community Expert
Community Expert
February 20, 2023

Use a custom Validation or Custom Format Script

if(event.value && event.value.toString().length)
  event.target.strokeColor = color.blue;
else
  event.target.strokeColor = color.red;

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
February 20, 2023

first of all thank you for your return but the problem is that the event does not work to fill out a form I have to go through this.getField I have already tested

Thom Parker
Community Expert
Community Expert
February 21, 2023

The script I posted is correct and works.

 

Did you try it out?  In what event did you enter it?

Were any errors reported in the Console Window (Ctrl-J)?

 

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