Skip to main content
Inspiring
February 19, 2024
Answered

How to delete characters at the end of form field?

  • February 19, 2024
  • 1 reply
  • 748 views

I have a digital signature field and when it is signed, it copies the name to another field like below:


var f = this.getField("Signature");
var sigInfo = f.signatureInfo();
var cert = sigInfo.certificates[0];
this.getField("Signature Name").value = cert.subjectDN.cn;

 

However, because the DN has the serial number baked into it, it appears there is no way for me to omit it.  So the only work around I can think of is to remove all the numbers from it or just delete the last six characters (which are numbers).

 

Question is how can I do that?

 

This topic has been closed for replies.
Correct answer Thom Parker

Try this:

 

this.getField("Signature Name").value = cert.subjectDN.cn.toString().slice(0,-6);

 

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
February 19, 2024

Try this:

 

this.getField("Signature Name").value = cert.subjectDN.cn.toString().slice(0,-6);

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
MBChelsAuthor
Inspiring
February 19, 2024

That'll do it!  Thank you sir!