Copy link to clipboard
Copied
Hi,
i know how to limit character in one filed in Acobat, but how can I limit characters to 250 in three linked fields? Fields are linked with this script:
Field 1
var t=this.getField("Fileld 2");
if (event.fieldFull) {
getField("Field 2").setFocus();
}
Copy link to clipboard
Copied
As I said, it should still work, even if it disappears.
The only solution is to place the code in a doc-level function and then call that function from the event.
So like this:
// Doc-level script
function validateFieldsLength() {
var newValue = AFMergeChange(event);
var otherText = this.getField("Field2").valueAsString;
var maxTextLength = 100;
if ((newValue.length + otherText.length) > maxTextLength) {
app.alert("The combined text may not exceed " + maxTextLength + " characters.");
event.rc = false;
}
}
// Field-level script - Keystroke event
validateFieldsLength();
Copy link to clipboard
Copied
You can use a custom-made KeyStroke script to calculate the length of the text in the current field, plus the text in the other fields, and then reject the value based on the total length.
Copy link to clipboard
Copied
Thank you try67.
Can you help me with write this KeyStroke? I searched for some solutions but I'm not into JS and it's too difficult for me
Copy link to clipboard
Copied
Here's an example. Note the code might "disappear" when you apply it (due to a bug in Acrobat), but it should still work:
var newValue = AFMergeChange(event);
var otherText = this.getField("Field2").valueAsString;
var maxTextLength = 100;
if ((newValue.length + otherText.length) > maxTextLength) {
app.alert("The combined text may not exceed " + maxTextLength + " characters.");
event.rc = false;
}
Copy link to clipboard
Copied
Unfortunately code "disappear" as you said.
Maybe you have another solution / some tip for this bug?
Copy link to clipboard
Copied
As I said, it should still work, even if it disappears.
The only solution is to place the code in a doc-level function and then call that function from the event.
So like this:
// Doc-level script
function validateFieldsLength() {
var newValue = AFMergeChange(event);
var otherText = this.getField("Field2").valueAsString;
var maxTextLength = 100;
if ((newValue.length + otherText.length) > maxTextLength) {
app.alert("The combined text may not exceed " + maxTextLength + " characters.");
event.rc = false;
}
}
// Field-level script - Keystroke event
validateFieldsLength();
Copy link to clipboard
Copied
TRY67 this version working fine, thank you very much!