• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Java script Help!

Community Beginner ,
May 07, 2020 May 07, 2020

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?

TOPICS
Acrobat SDK and JavaScript

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , May 07, 2020 May 07, 2020

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);

 

 

Votes

Translate

Translate
Community Expert , May 07, 2020 May 07, 2020

Yes, remove that script and add this one instead:

if (event.value) event.value = "/" + event.value.replace(/^\//, "").replace(/\/$/, "") + "/";

Votes

Translate

Translate
Community Expert ,
May 07, 2020 May 07, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 07, 2020 May 07, 2020

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?

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 07, 2020 May 07, 2020

Copy link to clipboard

Copied

I meant, do I remove the format script and put that in the validation?*

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 07, 2020 May 07, 2020

Copy link to clipboard

Copied

Yes, remove that script and add this one instead:

if (event.value) event.value = "/" + event.value.replace(/^\//, "").replace(/\/$/, "") + "/";

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 07, 2020 May 07, 2020

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?

 

NDAQ_0-1588883457933.png

NDAQ_1-1588883489543.png

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 07, 2020 May 07, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 07, 2020 May 07, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 07, 2020 May 07, 2020

Copy link to clipboard

Copied

I would do it the other way around. Leave the keystroke script in place and remove the validation script.

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 15, 2020 May 15, 2020

Copy link to clipboard

Copied

Thanks! I actually tried both ways.  It works when in Adobe but does not carry over to e-sign. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 15, 2020 May 15, 2020

Copy link to clipboard

Copied

Adobe Sign has very little support for scripts in a PDF file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 15, 2020 May 15, 2020

Copy link to clipboard

Copied

LATEST

Thanks, totally realized this in my testing.  Thanks for the help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 07, 2020 May 07, 2020

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);

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines