Code For Extracting Initials From A Full Name Text Field to Another Text Field
Copy link to clipboard
Copied
Hello!
I'm having trouble with entering a code in Adobe Acrobat X Standard to take the initials from a full name text field to another text field in the form. I'm working on developing an electronic time sheet for my company and we want the field technician's to be able to enter their full name at the top into a fillable field and then the form will take their initials from that field and populate several fields below to "sign off" on their breaks throughout the day. The less effort they have to put into their time sheet, the better this process will work.
Hopefully someone can help!
Thank you,
Janelle
Copy link to clipboard
Copied
I think that you hit the wrong forum, you need the Acrobat forum.
Copy link to clipboard
Copied
Thank you! Sorry about that.
Copy link to clipboard
Copied
[moved from ActionScript 3 to PDF Forms]
Copy link to clipboard
Copied
What about hyphenated first/last names? For example "Jean-Paul Gaultier". Should it be "J.P.G." or just "J.G."? Or people with multiple last names, like "Frederik Willem de Klerk". Is it "F.W.d.K."? "F.W.D.K.", etc. There are specific rules and customs about how to initialize such names and it's never good to assume or force someone to do it in a way they don't want to. Better have them do it themselves once, and then copy it automatically the rest of the locations where you want it to appear.
Copy link to clipboard
Copied
Or,
John Wood Campbell Jr. (JWCJ?)
Loudon Wainright III (LWI?)
Copy link to clipboard
Copied
I would create at least 3 fields, Name.first, Name.MI, and Name.last. I could then extract the first letter from each of the fields and generate the needed initial string. If I needed one field with the whole name, I would just concatenate the 3 fields with a space between the component parts.
Copy link to clipboard
Copied
I think this works:
event.value = this.getField("FullName").value.split(/[\s+\-]/).map(function(a){return a[0]}).join("");
Use the Acrobat JavaScript Reference early and often

