Link in Zwischenablage kopieren
Kopiert
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.
Link in Zwischenablage kopieren
Kopiert
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
Weitere Inspirationen, Events und Ressourcen finden Sie in der neuen Adobe Community
Jetzt ansehen