Copy link to clipboard
Copied
I want to verify that user's entry in a field ("Line41") equals "Line40 * .02" or is blank or zero. Customer will get a discount of 2% if paid by a certain date, otherwise entry on Line 41 will be zero (blank is acceptable). I don't want to use a straight calculation in "Line41" because not all customers will get the discount.
I'm using Adobe Acrobat DC. I'm a novice to JavaScript with a little experience. Your help is appreciated.
Use this code as the custom validation script of Line41:
var line40 = Number(this.getField("Line40").value);
var v = Number(event.value);
if (v!=0 && v!=(line40*0.2)) app.alert("Insert your warning message here.",1);
Copy link to clipboard
Copied
So what should happen if it's not those values? And what should happen if it is?
Copy link to clipboard
Copied
If user's entry does not equal, a popup message requesting they check their calculation. If is does equal, keep user's entry.
Copy link to clipboard
Copied
Use this code as the custom validation script of Line41:
var line40 = Number(this.getField("Line40").value);
var v = Number(event.value);
if (v!=0 && v!=(line40*0.2)) app.alert("Insert your warning message here.",1);
Copy link to clipboard
Copied
I entered that code and tested it. I'm getting the warning message the first time I enter data in Line 41, even if it is correct. If I return to the field using back-Tab (Shift + Tab) and re-enter the data, I don't get the message again. Am I doing something wrong? If user enters the correct data, I do not want the app alert. Perhaps I didn't state that clearly in my earlier message.
Copy link to clipboard
Copied
Can you share the file?