Copy link to clipboard
Copied
Is there a way to have a form field consist of 17 characters (that I know how to do) and then elsewhere in the same PDF have a field that uses only a subset of that field... such as the last 8 characters or only the first character.
Example field name is : MiddleName and later on I want field MiddleInitial which would autofill just the first letter of the field MiddleName.
or
Example field name is Claim_Number, (a 17 character field) and later on I want field Last8_Claim which would autofill with the last 8 characters of the field Claim_Number.
I feel like I have seen the answer somewhere but just can't find the right query phrase to bring up the script or validation or calculation etc...
Copy link to clipboard
Copied
Hi,
You can use the following as a reference.
First set the string length of the Claim_Number field using the following guidance :
https://answers.acrobatusers.com/set-field-based-string-length-field-q3335.aspx
Then use these other threads to see how a script is phrased to extract the desired strings:
https://answers.acrobatusers.com/Extract-First-Letter-from-Text-field-q102091.aspx
https://answers.acrobatusers.com/how-extract-characters-string-q41957.aspx
More in-depth resource about using strings:
https://acrobatusers.com/tutorials/splitting-and-rebuilding-strings/
Copy link to clipboard
Copied
Thanks everybody you got me to the right place .... and for other relative noobs like me here is the specifics.
First page of PDF has a field of 17 characters named Buy_VIN1
On several other pages I need just the last 8 characters of Buy_VIN1
On those other pages there is a text field named VIN1_R8 (doesn't really matter as that field name does not appear in the java script)
In the Form Editior mode I went to VIN1_R8 and in the CALCULATE box I entered the following:
var v1 = this.getField("Buy_VIN1").value;
var s1 = "";
if (v1.length > 0)
{
s1 = v1.substring(09,17);
}
event.value = String(s1);
Copy link to clipboard
Copied
Yes, you just need to copy a portion of the string entered into the field to a different field. The best way to do this is with the validation script on the first field, say the MiddleName field.
Use something like this to copy the first letter
this.getField("MiddleInitial").value = (event.value.length > 0)?event.value[0]:"";
Or to get the last 8 letters
this.getField("PartialName").value = (event.value.length > 8)?event.value.slice(event.value.length-8):event.value;
You just need to learn about the JavaScript string functions.
Here's an article that covers some of what you can do
https://acrobatusers.com/tutorials/splitting-and-rebuilding-strings/
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Hi,
You can use the following as a reference.
First set the string length of the Claim_Number field using the following guidance :
https://answers.acrobatusers.com/set-field-based-string-length-field-q3335.aspx
Then use these other threads to see how a script is phrased to extract the desired strings:
https://answers.acrobatusers.com/Extract-First-Letter-from-Text-field-q102091.aspx
https://answers.acrobatusers.com/how-extract-characters-string-q41957.aspx
More in-depth resource about using strings:
https://acrobatusers.com/tutorials/splitting-and-rebuilding-strings/
Copy link to clipboard
Copied
Thanks everybody you got me to the right place .... and for other relative noobs like me here is the specifics.
First page of PDF has a field of 17 characters named Buy_VIN1
On several other pages I need just the last 8 characters of Buy_VIN1
On those other pages there is a text field named VIN1_R8 (doesn't really matter as that field name does not appear in the java script)
In the Form Editior mode I went to VIN1_R8 and in the CALCULATE box I entered the following:
var v1 = this.getField("Buy_VIN1").value;
var s1 = "";
if (v1.length > 0)
{
s1 = v1.substring(09,17);
}
event.value = String(s1);
Copy link to clipboard
Copied
I love you so much right now! I was needing to grab the last 8 of VIN's also, and I couldn't get anything else to work. Thank you, thank you, thank you!
Copy link to clipboard
Copied
you are very welcome.....

