Error in Acrobat JavaScript Console
Copy link to clipboard
Copied
Hi, i have adobe pro xi & foxit phantom 6 in my pc. if i run bellow code in foxit JavaScript Console, working perfectly but if run same code in Acrobat JavaScript Console, giving error. can u pls help me find out the issue ??. thanks..
for (var i = 0; i < numFields; i++) {
var f = getField(getNthFieldName(i));
f.comb = false;
f.charLimit = false;
f.doNotSpellCheck = false;
f.doNotScroll = false;
Copy link to clipboard
Copied
There is a closing "}" missing. If that's not the problem, then what exactly is the error message you are getting?
Copy link to clipboard
Copied
One more thing: The properties you want to set would only be valid for text fields, so if you have any other field type in your document, then that is very likely the reason for the error message.
Copy link to clipboard
Copied
hi, i have add closing "}" & got bellow error. also my form has check boxes & radio buttons. thaks..
SyntaxError: syntax error
1:Console:Exec
undefined
Copy link to clipboard
Copied
It would be helpful if you were to post the entire error message. Unfortunately JavaScript is an interpreted language and comes to a halt at the first error encountered. This means you will debugging one error at a time.
Copy link to clipboard
Copied
hi, i have add closing "}" & got bellow error. also my form has check boxes & radio buttons. thaks..
SyntaxError: syntax error
1:Console:Exec
undefined
Copy link to clipboard
Copied
You may need to share your form or an example with the same issue for others to diagnose the problem.
Do you have fields that are other than text fields? If so, then you need to exclude them from being processed by testing the "type" property.
Copy link to clipboard
Copied
hi,my form has check boxes & radio buttons. thaks..
Copy link to clipboard
Copied
You then need to test the field's "type" property and only process the "text" type. Also the "charLimit" property requires an integer value and not a logical value.
Copy link to clipboard
Copied
In that case, there is something else wrong. When I run your script (as typed, just with the "}" added at the end), I get the following when the script encounters a non-text field:
InvalidSetError: Set not possible, invalid or unknown.
Field.comb:3:Console undefined:Exec
You are getting a syntax error, which you should not based on your script.
Do you know how to execute a multi-line script in the console window? Take a look here for a tutorial about how to use the console and how to execute code: https://acrobatusers.com/tutorials/javascript_console
Copy link to clipboard
Copied
Also, Phantom doesn't report errors like Acrobat does, so it very well didn't actually work there either.
Copy link to clipboard
Copied
hi, i have manage to work bellow code..
for (var i = 0; i < this.numFields; i++) {
var fNm = this.getNthFieldName(i);
var f = this.getField(fNm);
if (f.type == "text") {
f.doNotSpellCheck = false;
f.doNotScroll = false;
}
}
now i want add bellow two codes into same script.
f.comb = false;
f.charLimit = false;
my problem is if i add that two lines into above script, it's giving bellow error. pls help me. thanks..
RangeError: Invalid argument value.
Field.charLimit:15:Console undefined:Exec
false
Copy link to clipboard
Copied
charLimit is an numerical value
Copy link to clipboard
Copied
hi, actually what i want to do is, in my PDF form any text field has bellow options selected then i want to remove that selection. can u pls help me. thanks..
limit number of characters
comb of characters
Copy link to clipboard
Copied
I think there's a bug in Acrobat that prevents setting these properties. I've also encountered it a couple of times in the past...
Copy link to clipboard
Copied
hi, so as per u bellow code is correct ??
for (var i = 0; i < this.numFields; i++) {
var fNm = this.getNthFieldName(i);
var f = this.getField(fNm);
if (f.type == "text") {
f.doNotSpellCheck = false;
f.doNotScroll = false;
f.charLimit = false;
f.comb = false;
}
}
Copy link to clipboard
Copied
Almost. Try this line:
f.charLimit = 0;
Copy link to clipboard
Copied
sorry no luck. got bellow error.
RangeError: Invalid argument value.
Field.charLimit:13:Console undefined:Exec
false
Copy link to clipboard
Copied
As I said, I believe it's a bug. You should report it here: Feature Request/Bug Report Form
Copy link to clipboard
Copied
ok thanks.
Copy link to clipboard
Copied
Have you tried any other integer value than zero?
I have found any integer between 1 and 2,147,483,647 works without error. Certainly any number 1,000,000,000 or larger should be large enough to make the field appear to hold an unlimited number of characters.
Your script could read:
var f; // for field object;
for (var i = 0; i < this.numFields; i++)
{
f = this.getField(this.getNthFieldName(i));
if(f.type == "text")
{
f.comb = false;
f.charLimit = 2147483647;
f.doNotSpellCheck = false;
f.doNotScroll = false;
} // end type text;
} // end numFields;

