Copy link to clipboard
Copied
Hi,
I've got a simple function that I have added to the 'DocumentJavascripts' in Acrobat in order to change the style of a field. I know that for a single field, I can use the 'blur' and 'focus' triggers to run it.
But seeing as I need to apply this function to most of the fields in the PDF, is there an easier way of doing this? Is there a document wide event listener that would work?
I don't think this is important, but just in case the function I'm using is:
function Blurfield()
{
V=this.getField(event.targetName);
if (V.value.length==0)
{
V.borderStyle = border.s;
V.fillColor = color.transparent;
V.strokeColor = color.transparent;
}
}
Many Thanks,
Herb
There's no "global event listener", but you can use a simple script to do it. I assume you want to apply it to text fields, right?
If so, you can use this code from the JS Console to do it:
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f==null) continue;
if (f.type=="text") {
f.setAction("OnBlur", "Blurfield();");
}
}
Copy link to clipboard
Copied
There's no "global event listener", but you can use a simple script to do it. I assume you want to apply it to text fields, right?
If so, you can use this code from the JS Console to do it:
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f==null) continue;
if (f.type=="text") {
f.setAction("OnBlur", "Blurfield();");
}
}
Copy link to clipboard
Copied
Thanks for that. I was hoping there was a global event listener that would just resolve it easily, but I guess not.