In our leave request process, we need for leave request dates to all be in the same pay period. Request dates (Date of Leave) are entered in a table, and the pay period dates (PPE) are populated from a lookup.
I'd like to find a way to alert users when additional dates entered in the table do not match the PPE of the first entry, or the PPE dates do not all match each other. I started to cobble together javascript based on information in this post but obviously I am missing something:
$(document).ready(function(){
register();
$('.RequestTypeDetails').click(register);
window.Parsley.addValidator('notequalto', {
validateString: function(value) {
var valueLookup = $('.PPEdate change').map(function() {return $(this).val(); }).get();
return _.filter(valueLookup, function(v) { return v !== value }).length == 1;
},
messages: {
en: 'Leave dates must be in the same pay period!',
}
});
function register()
{
$('.PPEdate change').attr('data-parsley-notequalto', '');
$('.PPEdate change').change(function(){
$('.PPEdate change').each(function(index, el){$(el).parsley().validate();})
});
}
});
Thank you for any assistance.