Copy link to clipboard
Copied
I'm trying to create a format for a field in my PDF.
Custom Format Script:
event.value="/" +event.value + "/";
Custom Keystroke Script:
event.rc = /^[A-Z]*$/.test
(event.change);
I'm hoping the outcome that the what ever is entered in this field starts with "/" and ends "/". - when testing for e-sign, it did not warn the signor to use the "/" and "/" and they were able to move to hte next field and sign the document.
How can build this script to make it a requirement?
2 Correct answers
Delete the format script and move the code to the keystroke script, but it needs to distinguish between the real keystroke and the commit.
if(event.willCommit)
event.value="/" +event.value + "/";
else
event.rc = /^[A-Z]*$/.test(event.change);
Yes, remove that script and add this one instead:
if (event.value) event.value = "/" + event.value.replace(/^\//, "").replace(/\/$/, "") + "/";
Copy link to clipboard
Copied
Do you want the field value to actually have those characters in it, or just to appear as if it does?
If the former then using the Format event will not achieve that. You can use the Validation event to force it.
Copy link to clipboard
Copied
I want the field to actually have those characters. Would I get rid of teh keystroke script and add that to the validation?
Copy link to clipboard
Copied
I meant, do I remove the format script and put that in the validation?*
Copy link to clipboard
Copied
Yes, remove that script and add this one instead:
if (event.value) event.value = "/" + event.value.replace(/^\//, "").replace(/\/$/, "") + "/";
Copy link to clipboard
Copied
Thank you!!! I appreciate it so much, this is a pain! it still didn't work - i think the issue is trying to fill the form out in adobe e-sign. could that be an issue?
Copy link to clipboard
Copied
My goal is for it to display on the form as:
/John Doe/
and not allow them to move to next field without that format.
Copy link to clipboard
Copied
Don't use Adobe Sign, and remove the first part of the Keystroke script.
Also, it's not a good idea to "lock" the user into a specific field. I recommend you don't do that.
Copy link to clipboard
Copied
I would do it the other way around. Leave the keystroke script in place and remove the validation script.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Thanks! I actually tried both ways. It works when in Adobe but does not carry over to e-sign.
Copy link to clipboard
Copied
Adobe Sign has very little support for scripts in a PDF file.
Copy link to clipboard
Copied
Thanks, totally realized this in my testing. Thanks for the help!
Copy link to clipboard
Copied
Delete the format script and move the code to the keystroke script, but it needs to distinguish between the real keystroke and the commit.
if(event.willCommit)
event.value="/" +event.value + "/";
else
event.rc = /^[A-Z]*$/.test(event.change);
Use the Acrobat JavaScript Reference early and often

