Copy link to clipboard
Copied
Ok, so I've been through the forums and thanks to the SME's have identified a successful method (utilizing a hidden field) to trigger an alert if the total of three (3) fields exceeds 100%. The discussions on validating below the 100% threshold have shown why utilizing a calculation script would be, at best, problematic.
With all that being said, I am still attempting to work out validation for <100% threshold by way of validation scripts within the fields: "Percent_01", "Percent_02", "Percent_03". The "Percent_Total" remains a hidden field for >100% alert and should not factor into the validation scripts, and the "next_field" as a placeholder for whatever the field is to be named.
//Thus far, I am placing the following script in the format tab custom format script for all "Percent" fields:
if (event.value) event.value += "%";
//Percent_01 contains the following validation script:
if (event.value=100) { this.getField("Next_Field").setFocus();
} else {
(event.value <100) (this.getField("Percent_02").setFocus());
}
//Percent_02 contains the following validation scrip
//Percent_03 contains the following validation script:
event.value = this.getField("Percent_01").value + this.getField("Percent_02").value + this.getField("Percent_03").value;
if (Number(event.value)>100) {
app.alert("Total percentage of benefits to be paid exceeds 100%. Your total is : " + event.value + "% Please try again.");
this.resetForm(["Percent_01", "Percent_02", "Percent_03"]);
this.getField("Percent_01").setFocus();
}
Independently, the script for exceeding the maximum value works like a champ. I have yet to get the below 100% to even work... issues like automatically displaying 100% in the field to not executing to the following field in order. Any assistance is, as always, much appreciated. 🙂
FYI:
x= means "x becomes equal to" and x== means "x is equal to", so you must write:
if (event.value==100) {...
with a double-equal sign!
@+
Copy link to clipboard
Copied
FYI:
x= means "x becomes equal to" and x== means "x is equal to", so you must write:
if (event.value==100) {...
with a double-equal sign!
@+