Copy link to clipboard
Copied
Hello,
I'm creating a grant application form with the following items:
A = total cost of project
B = deduct total amount of funds already on hand
C = total grant amount being applied for
The calculation is A-B=C.
The valadation is: $0=> C <= $100,000.
If A = $150,000 and B = -$90,000, then C = $60,000.
Because the calculation is automatically updated as soon as A is entered (and B has not been entered), then C = $150,000 which automatically triggers an error message.
What would be the script to allow A to be >= $100,000, but yet C still has to be <= $100,000 once A and B are entered. I tried playing with an IF-THEN statement, but no luck. I don't want users to enter B first as it seems counterintuituve to start with a negative number in this scenario. Any suggestions? Thanks.
Because the calculation is automatically updated as soon as A is entered
You can set in a script to calculate only when A and B fields are filled.
Copy link to clipboard
Copied
What script do you use?
Copy link to clipboard
Copied
I don't have a script at the moment, so that is why I'm looking for a solution. I'm very new to writing scripts.
Copy link to clipboard
Copied
What should be the value of C if only A (or only B) are filled in, then?
Copy link to clipboard
Copied
The value of C is the total when A - B is calculated. I don't want the value of C to be calculated and then validated until both A and B are entered. At the validation, C must be <= $100,000. The values of A and/or B could be "0".
Example: A = $150,000 and B = -$90,000.
If you do the math on a piece of paper and as soon as you are finished writing $150,000, your brain doesn't trigger an error message because A is >=$100,000. Rather, your brain waits for B to be written as -$90,000 before doing the calculation of $150,000-$90.000 and determing the result is $60,000 which is <=$100,000; thus, no error message gets triggered.
then C = $60,000.
Because the calculation is automatically updated as soon as A is entered (and B has not been entered), then C = $150,000 which automatically triggers an error message.
Copy link to clipboard
Copied
You can't validate a calculated field. Validation means checking the value and either accepting or rejecting it. This needs to be done in the fields that contain values the user enters, not ones with a calculated value.
You can replace the "bad" result with zero, or nothing, or "ERROR", but you can't reject it.
Copy link to clipboard
Copied
Because the calculation is automatically updated as soon as A is entered
You can set in a script to calculate only when A and B fields are filled.
Copy link to clipboard
Copied
Thank you Try67 and Nesa. I ended up writing a simple script to give an error message under the text box if the value of C is >$100,000.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now