Skip to main content
Nikolaos.
Inspiring
June 27, 2024
Question

Text field as "Required", automatically remove red border after text-value input.

  • June 27, 2024
  • 3 replies
  • 1542 views

After marking a text field as "Required", the red border should be automatically removed after entering a value or text. How can I do this in Adobe Acrobat Pro 2020? so that the form works in the free Acrobat Reader.

This topic has been closed for replies.

3 replies

JR Boulay
Community Expert
Community Expert
June 28, 2024

Why simplify when you can complicate?

🙂

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
Community Expert
June 27, 2024

- Don't use the "required" option for the fields, or deactivate highlighting by placing this code as a Document Level script:

app.runtimeHighlight = false;

 

- Use the Appearance options to put a red stroke to the fields.

 

- Place this code as an "On Blur" action in the fields:

if (event.target.value === event.target.defaultValue) {event.target.strokeColor = color.red;}
else {event.target.strokeColor = color.transparent;}

 

Acrobate du PDF, InDesigner et Photoshopographe
Nikolaos.
Nikolaos.Author
Inspiring
June 27, 2024

Thanks for the information. I solved it with this code and it actually works great.

var fieldName = "Textfiled1.0"; 
function updateBorderColor() {
    var field = this.getField(fieldName);
    if (field.value !== "") {
        field.borderColor = color.transparent; 
    } else {
        field.borderColor = color.red; 
    }
}

this.getField(fieldName).setAction("Validate", "updateBorderColor();");
this.getField(fieldName).setAction("Keystroke", "updateBorderColor();");
this.getField(fieldName).setAction("Custom", "updateBorderColor();");
updateBorderColor();

 

Thx again.

Bernd Alheit
Community Expert
Community Expert
June 28, 2024

Where do you use this script?

JR Boulay
Community Expert
Community Expert
June 27, 2024

Red highlights are like blue backgrounds: they cannot be printed.
And they work the same in Acrobat Reader.

Acrobate du PDF, InDesigner et Photoshopographe
Nikolaos.
Nikolaos.Author
Inspiring
June 27, 2024

I'm not interested in printing, but in the user interface. The user should be able to see the red border on the screen and after entering something the red border should disappear and this should repeat as long as there is text or no text in the field. I probably need java script and step-by-step instructions for a beginner :-).