Calculate Value of Fields if Checkbox is Triggered
Hello All,
I am probably making this more complicated than it needs to be, but I want to test the totals of 2 fields in the form that I have created.
I have a hidden field ("Split Test") that should add together the 2 fields ("Amount To Be Paid On First Card" & "Amount To Be Paid On Second Card") if the checkbox marking the payment as multiple is checked ("MP Yes"). This checkbox is not a radio button, there is a checkbox for Yes and a checkbox for No. No is the default selection.
There is an app.alert within the code that needs to inform the user that the amounts for the cards cannot equal less than $99 or more than $1749. But, if the multiple payment box hasn't been checked, this should not be tested at all.
I have tried several different variations of code that I have found, inclusive of adjusting the codes that I already have in place, but to no avail.
Any assistance that can be provided would be appreciated.
I did find a way to trigger it so that it would add together and clear the fields if the amount was over or under the max or min. However, what I have found is that the box checks it whether it is a multiple payment or not, which is confusing if you don't know what is happening (as the second payment fields are all hidden unless the multiple payment Yes checkbox has been checked.
This is what I had that *did* work, sort of:
[This goes in the custom calculation field of Split Test]
var a = Number(this.getField("Amount To Be Paid On First Card").valueAsString);
var b = Number(this.getField("Amount To Be Paid On Second Card").valueAsString);
event.value = a+b;
if (event.value <99 || event.value >1749)
{event.value = "";
app.alert("Multiple credit card payments cannot equal less than $99 or more than $1,749");
}
[This goes in the custom calculation field of Amount to be Paid on First Card and Amount to be Paid on Second Card]
var v = this.getField("Split Test").valueAsString;
if (v==0) event.value=""
Please help.
