Copy link to clipboard
Copied
I need the user to enter a dollar amount in field A then reenter it in field B. I want to compare fields A and B and throw and error if they don't match. how do I do this? i have ZERO java experience so dumb it down for me!! thanks.
For "Borrower 1 Amount":
if (event.value && event.value!=this.getField("Borrower 2 Amount Re-enter").valueAsString) app.alert("Error! This value must match that of \"Borrower 2 Amount Re-enter\".");
For "Borrower 2 Amount Re-enter":
if (event.value && event.value!=this.getField("Borrower 1 Amount").valueAsString) app.alert("Error! This value must match that of \"Borrower 1 Amount\".");
Copy link to clipboard
Copied
An important point is that you do not use Java, you use JavaScript (one word, never shortened to Java). The reason to point this out is, if you go searching the web for advice on Java, you will get information that is useless to you. Must be JavaScript; it must be Acrobat JavaScript, which is a special type.
Copy link to clipboard
Copied
You can use this code as the custom validation script of field B:
if (event.value && event.value!=this.getField("A").valueAsString) app.alert("Error! This value must match that of field A.");
You should also enter the same thing (adjust the field names, of course) under field A, in case they change it after having changed B.
Copy link to clipboard
Copied
ok - so if my fields are called the following, what would the custom validation script say, specifically?
Thanks in advance.
Copy link to clipboard
Copied
For "Borrower 1 Amount":
if (event.value && event.value!=this.getField("Borrower 2 Amount Re-enter").valueAsString) app.alert("Error! This value must match that of \"Borrower 2 Amount Re-enter\".");
For "Borrower 2 Amount Re-enter":
if (event.value && event.value!=this.getField("Borrower 1 Amount").valueAsString) app.alert("Error! This value must match that of \"Borrower 1 Amount\".");
Copy link to clipboard
Copied
You might want to add an additional check to see if the other field value you're comparing event.value to isn't blank. I'd find it annoying and probably confusing to get that error message in such cases, at least for the first field.