Copy link to clipboard
Copied
Hello,
I'm working on an error check that looking at "S3 Breakfast meal count" and if it is greater than 0 then I need it to look at the other two and if either one of those is greater than 0 (or both are) its okay and doesn’t return my error code. However, if S3 Breakfast Meal count is greater than 0 and the other two are not greater than 0 two I need my error to return.
Here’s my code to date…
if (this.getField("*S3 B Meal Count").value >0 && this.getField (("S3 Add <= Count").value >0) or (this.getField ("S3 Add > Count").value >0)) event.value = "";
else event.value = "Add meal count for additional amount for lunch.";
Part of the above works…
For the or I’ve tried && and ||. The || is only looking at the last half if its true it removes my code. I tried doing a var script, but I couldn’t work that one out in my head.
And yes, I know my field names stink, but I didn’t know anything about JavaScript when I developed my field name schema for this form (two years ago).
I think I'm close with my code.
Any help is apprecaited.
Copy link to clipboard
Copied
Try this:
if (this.getField("*S3 B Meal Count").value >0 && (this.getField ("S3 Add <= Count").value >0 || this.getField ("S3 Add > Count").value >0)) event.value = "";
else event.value = "Add meal count for additional amount for lunch.";
Copy link to clipboard
Copied
thanks...I'm closer...the issue now is that the else is appear if "*S3 B Meal Count" is 0.
if (this.getField ("*S3 B Meal Count").value > 0 && (this.getField ("S3 Add <= Count").value >0 || this.getField ("S3 Add > Count").value >0)) event.value = "";
else event.value = "Add meal count for additional amount for lunch.";
Would a var solve the problem...
var EC10 = this.getField ("*S3 B Meal Count").value;
if EC10 > 0 && (this.getField ("S3 Add <= Count").value >0 || this.getField ("S3 Add > Count").value >0)) event.value = "";
else event.value = "Add meal count for additional amount for lunch.";
But there is an error in that...
Again, I'm learning by trial and error.
Copy link to clipboard
Copied
May be that "*S3 B Meal Count" is not exact 0.
Copy link to clipboard
Copied
clueless..what does that look like
Copy link to clipboard
Copied
There's no difference between applying a value to a var or examining it directly.
Copy link to clipboard
Copied
thanks