I have two fields (Maximum budget allowance and Total Funds) and am trying to add validation to them so that they must match. The Total Funds field is a read only total of all the funds fields above it. I am trying to use the same logic from this post: https://answers.laserfiche.com/questions/155386/Javascript-compare-multiple-fields#155415
But I cannot get Maximum budget allowance field to revalidate when the different Funds fields are entered. When I manually delete the field and reenter the correct total, it then validates correctly. Here is the code:
"totalBudget" is the Maximum budget allowance field, "totalFunds" is the Total Funds field, "funds" is all the Funds fields.
$(document).ready(function(){
$(".totalBudget input").attr('data-parsley-duplicate-checker','.totalFunds');
$(".funds input").attr('data-parsley-trigger','focusout');
$(".funds input").attr('data-parsley-trigger-after-failure','input');
window.Parsley.addValidator("duplicateChecker", {
validateString: function(fieldValue) {
let values = $(".totalFunds input").map(function() { return $(this).val(); });
let existing = _.filter(values, function(value) {
return fieldValue == value;
});
return existing.length == 1;
},
messages: {
en: "Total Funds must match budget"
}
});
});
Please help me!