I want an alert message to appear when one number field does not equal the sum of 6 other number fields. Right now the following script makes the warning message appear whether or not the sum equals the entry into the "Cash 2010" number field. What do I need to do to make the warning message disappear when the sum field does equal the sum?
(function () {
// Get field values, as numbers
var a = +getField("1 to 999 Total");
var b = +getField("1000 to 4999 Total");
var c = +getField("5000 to 24999 Total");
var d = +getField("25000 to 49999 Total");
var e = +getField("50000 to 99999 Total");
var f = +getField("100000 Total");
// Get the value the user entered into this field, as a number
var g = +event.value;
if (g != (a+b+c+d+e+f)) {
// Alert user
app.alert("Cash Donations in the Cash Donation 2010 field must be equal to the total donations listed above in the 'Total Amount' row for ‘Number of Donors and Gift Size Last FY.’ Remember to include foundation and government grants in both sections.");
} })();
a = 1
b = 2
c = 3
d = 4
e = 5
f = 6
g = 21
You may need to round the sum and the "g" value to the same precision before doing the comparison.