-
1. Re: If Else Statement in Validation of Other Field's Values
MichaelN Sep 8, 2013 4:41 PM (in response to lmphil)Use this script as the custom calculation script for the "Total" field.
This script assumes there are 2 fields, "Remaining Balance" and "Total":
var b = getField("Remaining Balance").value;
if (b > 3000){
getField("Total").value = 3000;
}
else getField("Total").value = b;Hope this helps.
-
2. Re: If Else Statement in Validation of Other Field's Values
try67 Sep 8, 2013 11:47 PM (in response to MichaelN)There are two problems with your code:
1. In a Calculation script one should apply the new value using event.value, not by using the getField method.
2. You should convert the value of "Remaining Balance" to a number explictly.
So the code should be:
var b = Number(this.getField("Remaining Balance").value);
if (b > 3000){
event.value = 3000;
} else event.value = b;
-
3. Re: If Else Statement in Validation of Other Field's Values
lmphil Sep 9, 2013 7:55 AM (in response to try67)Thank you very much for your response. I copied/pasted the code, but it is not working in my document. Any suggestions?
-
4. Re: If Else Statement in Validation of Other Field's Values
try67 Sep 9, 2013 11:41 AM (in response to lmphil)You'll need to provide more information... Are there any error messages in the JS console? What exactly is happening?
If you wish, you can share the file with me at try6767@gmail.com .
-
5. Re: If Else Statement in Validation of Other Field's Values
MichaelN Sep 9, 2013 5:58 PM (in response to try67)Gilad D (try67) wrote:
There are two problems with your code:
1. In a Calculation script one should apply the new value using event.value, not by using the getField method.
2. You should convert the value of "Remaining Balance" to a number explictly.
So the code should be:
var b = Number(this.getField("Remaining Balance").value);
if (b > 3000){
event.value = 3000;
} else event.value = b;
I see, thanks Gilad.
-
6. Re: If Else Statement in Validation of Other Field's Values
lmphil Sep 10, 2013 9:21 AM (in response to MichaelN)Works great! Thank you both very much!



