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

Javascript to Make an Autofill Editable

Explorer ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

I am creating a form with mutli pay options available.

 

I would like the first payment amount ("Amount To Be Paid on First Card") to autofill with the total amount but be editable if the total amount ("Amount To Be Paid") is to be split.  In that event, I would also like other fields ("Amount To Be Paid on Second Card") to become required if the first amount is lesser than the total amount.

 

I am entering the following code into the Amount To Be Paid on First Card custom calculation script field.

It pulls the auto fill, it makes the secondary payment field required, but it does not allow the amount to be changed from the autofill of the total amount.

I am still learning (mostly from this community) and would appreciate any help that can be offered.  My attempt is below.  Thank you for any assistance.

 

event.value = this.getField("Amount To Be Paid").value;

var n = this.getField("Amount To Be Paid On First Card").value;

if (n < "Amount To Be Paid On First Card") {
	testMyField(event.value, "Amount To Be Paid On Second Card");
}

 

TOPICS
Acrobat SDK and JavaScript , Windows

Views

439

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 1 Correct answer

Community Expert , Mar 01, 2021 Mar 01, 2021

Do you use some checkbox or something when you want to split?

For example you have checkbox that you select when you need to split balance,that could activate script to allow you to enter value in first field and set second field to required.

Lets say checkbox name is "Split" you can replace your script with this:

event.value = this.getField("Amount To Be Paid").value;
if(this.getField("Split").valueAsString != "Off"){
event.rc = false;
this.getField("Amount To Be Paid On Second Card").required = t
...

Votes

Translate

Translate
Community Expert ,
Mar 01, 2021 Mar 01, 2021

Copy link to clipboard

Copied

What software do you use?

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
Explorer ,
Mar 01, 2021 Mar 01, 2021

Copy link to clipboard

Copied

Adobe Acrobat Pro

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 ,
Mar 01, 2021 Mar 01, 2021

Copy link to clipboard

Copied

Do you use some checkbox or something when you want to split?

For example you have checkbox that you select when you need to split balance,that could activate script to allow you to enter value in first field and set second field to required.

Lets say checkbox name is "Split" you can replace your script with this:

event.value = this.getField("Amount To Be Paid").value;
if(this.getField("Split").valueAsString != "Off"){
event.rc = false;
this.getField("Amount To Be Paid On Second Card").required = true;}
else {
this.getField("Amount To Be Paid On Second Card").value = "";
this.getField("Amount To Be Paid On Second Card").required = false;}

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
Explorer ,
Mar 01, 2021 Mar 01, 2021

Copy link to clipboard

Copied

LATEST

I don't, no.

Currently, it is all fields and drop downs for payment information, billing information, and amount.

I know that my script has conflicts.  I'm instructing it copy information and to make fields required in the even that the amount in the second field is lesser than the amount in the above.

I'm not knowledgable enough to figure out how to instruct it to bypass the autofill if it is changed by the user; so, even if I were to type an amount into the second feild, it readjusts and autopopulates with the data from the first field.

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