Copy link to clipboard
Copied
I have a form that is about 200 text fields. Is there a way to use a general onblur / onfocus for all of them? adding the same javascript for all of them is a pain in the .......
Yes, that's possible, using this code:
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("OnFocus", " // enter on focus code here");
f.setAction("OnBlur", " // enter on blur code here");
}
}
Copy link to clipboard
Copied
Using Javascript you can set actions of the fields.
Copy link to clipboard
Copied
To do this is very time intensive as I have over 200 fields on the PDF
Copy link to clipboard
Copied
Yes, that's possible, using this code:
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("OnFocus", " // enter on focus code here");
f.setAction("OnBlur", " // enter on blur code here");
}
}
Copy link to clipboard
Copied
Is this a one time use code or part of the PDF?
Copy link to clipboard
Copied
Where would I put this code?
Copy link to clipboard
Copied
It's for a one-time use. You can run it from the JS Console, or even a button field.
Copy link to clipboard
Copied
I have added alot of the actions already. What would be the test for the action?
if (!f.setAction("onBlur")){dothis}
Copy link to clipboard
Copied
Not possible. The script can't know if a field already has an action associated with it.
Copy link to clipboard
Copied
What happens if there is an action already there?
Copy link to clipboard
Copied
It will be overwritten by the new code.
Copy link to clipboard
Copied
AWESOME!!
Copy link to clipboard
Copied
You just saved me about 4 hours of time. Thanks very much