Skip to main content
ZombieLuna
Inspiring
February 28, 2021
Answered

Javascript to Make an Autofill Editable

  • February 28, 2021
  • 1 reply
  • 903 views

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

 

This topic has been closed for replies.
Correct answer Nesa Nurani

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

1 reply

Nesa Nurani
Community Expert
Community Expert
March 1, 2021

What software do you use?

ZombieLuna
Inspiring
March 1, 2021

Adobe Acrobat Pro

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
March 1, 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 = true;}
else {
this.getField("Amount To Be Paid On Second Card").value = "";
this.getField("Amount To Be Paid On Second Card").required = false;}