I am trying to validate two values in each row of a table. The 'Total Budget' should match the 'Sources Total', which is made up of all the user editable fields in this table.
The CSS classes are as follows: table is "PFSTable", the 'Total Budget' field is "total_budget_pfs", and the 'Sources Total' is 'total_sources_pfs'.
$(document).ready(function () { window.Parsley.addValidator('notequalto', { validateString: function(value) { return value == $('.total_budget_pfs input').val(); }, messages: { en: 'Values do not match!' } }); // register validator on existing rows registerValidator(); }); function registerValidator(){ // assign validator $('.PFSTable input').attr('data-parsley-notequalto','.total_sources_pfs input'); }
With this code, it works correctly on the first row in the table. However, every other row is still pointed to the first row for validation.
Any ideas?