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

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

Contributor ,
Jun 27, 2024 Jun 27, 2024

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
1.3K
Translate
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

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


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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

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

Translate
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

- 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
Translate
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

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.

Translate
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
LATEST

Where do you use this script?

Translate
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

Why simplify when you can complicate?

🙂


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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