Copy link to clipboard
Copied
Hi there,
I am wondering what the JavaScript for turning off the "Highlight Colour" on a text box once you have filled it in - Adobe Form - is ?
I would like to add it as a "Mouse Exit" - action.
Thank you in advance!
Copy link to clipboard
Copied
You'll first need to disable the normal runtime highlight in a document level script using...
app.runtimeHighlight = false;
Then in the format script of each field, add the following...
var field = event.target;
if (field.value == field.defaultValue) {
field.fillColor = color.cyan; // for example
}
else {
field.fillColor = color.transparent;
}
The format script runs last so that's the place to put the code. In this case, you're formatting the appearance of the field rather than formatting the value though.
Copy link to clipboard
Copied
Hi Joel,
Thanks a lot for your help. This solved the problem. However, I did read somewhere that if you add the normal app runtime highlight to the document, it affects all of your other documents, as well as all the documents for the person who receives the form. Is there a way to not have this happen, or undo the script after if needed? I tried deleting the script to see if it would undo it, but it didn't. It still keeps the transparent highlight.
Thank you!
Copy link to clipboard
Copied
You are correct. Turning off the highlight via scripting does (though at one time it didn't, and really shouldn't) change the user preference.
You can set the property back to true in the document WillClose action. That should allow other documents to act normally.
Copy link to clipboard
Copied
Do you mind ellaborating on what you mean by "set the property back to true" in the Document Will Close action. I understand I have to do it through this path: Tools > JavaScript > Document Actions > Document Will Close > Edit
but then I am not sure what to do to set it to "true".
Thank you!
Copy link to clipboard
Copied
It's the same as above but in reverse.
app.runtimeHighlight = true;