Copy link to clipboard
Copied
Hello,
New here so I need some help.
How do I get a popup whenever the calculated field is less than 4 AND another field called "super" has a number value greater than zero.
This is what I have and the "super" field doesn't seem to have any effect on the popup.
var s = this.getField("super").value;
if(event.value<4&&s>0);
app.alert("All 4 requirements must be met in order to qualify for the super rebate amount.")
Copy link to clipboard
Copied
remove the semicolon at the end of the if condition.
Copy link to clipboard
Copied
Thanks, but the behavior didn't improve after I removed the semicolon. What I want is that there should be no popup unless the "super" field has a value AND the event field is less than 4.
What I have now:
var s = this.getField("super").value;
if(event.value<4&&s>0) app.alert("All 4 requirements must be met in order to qualify for the super rebate amount.")
Currently, the alert still pops up whenever the event field is less than zero regardless of what the "super" field value is. It's not taking into account the value of the "super" field.
I'm not sure if it matters, but the event field is the sum of 4 checkboxes, each with an export value of 1. And the "super" field is what the user would put in,
Copy link to clipboard
Copied
Where did you put script?
Check that event value is higher than zero otherwise if field is empty or 0 and 'super' higher than 0 it will still pop alert.
Copy link to clipboard
Copied
The script is in validation.
Sorry!! I misspoken.
Currently, the alert still pops up whenever the event field is less than 4 (not zero) regardless of what the "super" field value is. It's not taking into account the value of the "super" field.
Thanks in advance for your help.
Copy link to clipboard
Copied
I want to make it so that the pop alert would ONLY occur when the "super" has a value AND the event value is less than 4.
Copy link to clipboard
Copied
O, I figured it out. I should have put the script with the 'super' rather than the previous event, which is labeled here as '4superReq'. Thanks for the effort in trying to help me figure it out.
var s = this.getField("4superReq").value
if((event.value>0)&&(s<4)) app.alert("All 4 requirements must be met in order to qualify for the super rebate amount.")
Copy link to clipboard
Copied
Just a couple of things to lookout for, if used as validation of "super" alert will only pop when the value of "super" is changed, and it won't pop when "4superReq" is changed, so if there is a possibility that "4superReq" value will be changed after "super" then use script as 'Calculate'.
If used as current, when you change "super" value an alert will pop even if "4superReq" is empty or 0.
Copy link to clipboard
Copied
Your point is correct, but using the Calculate event for this is not a good idea, as the alert will show up each time you edit any field in the file (if the condition is true), unless you add additional conditions checking which field triggered the event. I would use the Validation event on both fields, instead.
Copy link to clipboard
Copied
Thanks so much for the responses. I'm learning so much. Now I understand some of the past behavior. I am interested to know how I can add a condition to check which field triggered the event. Is it by adding the Validation event on both fields? Please advise. Thanks.
Copy link to clipboard
Copied
The place to look for this information is the Acrobat JavaScript Reference.
See the "event.source" property.