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

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

Contributor ,
Jun 27, 2024 Jun 27, 2024

Copy link to clipboard

Copied

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.

TOPICS
How to , JavaScript , PDF

Views

121

Translate

Translate

Report

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 ,
Jun 27, 2024 Jun 27, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Contributor ,
Jun 27, 2024 Jun 27, 2024

Copy link to clipboard

Copied

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 :-).

Votes

Translate

Translate

Report

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 ,
Jun 27, 2024 Jun 27, 2024

Copy link to clipboard

Copied

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

 

Votes

Translate

Translate

Report

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
Contributor ,
Jun 27, 2024 Jun 27, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 ,
Jun 28, 2024 Jun 28, 2024

Copy link to clipboard

Copied

LATEST

Where do you use this script?

Votes

Translate

Translate

Report

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 ,
Jun 28, 2024 Jun 28, 2024

Copy link to clipboard

Copied

Why simplify when you can complicate?

🙂

Votes

Translate

Translate

Report

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