Beenden
  • Globale Community
    • Sprache:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Remove red highlight after checkbox is checked, Acrobat Pro DC

Neu hier ,
Sep 04, 2017 Sep 04, 2017

I have a form with required checkboxes highlighted in red.

I have successfully added javascript to remove this border from my text fields once filled in, by running a custom validation script, but this script does not work for checkboxes.
Can anyone help me with a script to simply remove the red border of a checkbox, once checked? I am new to javascript, so a script and location would be wonderful. Thanks in advance.

THEMEN
Acrobat SDK und JavaScript
1.7K
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Oct 31, 2017 Oct 31, 2017
AKTUELL

Checkboxes are particularly difficult to program like a text field.  First off, there are only two values, on and off, so how do you validate that? Second, while a checkbox has a validation and calculation script, they are not accessible from the Acrobat UI. 

So I'm assuming that this if for something like "I agree to the terms" check box?  You could use the mouse up event to check the value of the checkbox.

event.target.borderColor = (event.target.value == "Yes")?color.black:color.red;

But the "mouse up" only catches mouse and keyboard events.  If that is all you need, then use it. But if you need the form setup correctly when auto filled, then you need to use the validate or format event.  To use one of these you'll need to set the script programmatically from the JavaScript Console Window. Like this

this.getField("MyCheck").setAction("Validate","event.willCommit || (event.target.borderColor = (event.value == \"Yes\")?color.black:color.red);");

Where "MyCheck" is the name of your checkbox field

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

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines