Skip to content

Instantly share code, notes, and snippets.

@NimzyMaina
NimzyMaina / unique.js
Last active June 20, 2019 13:34
Jquery validation unique from other input (use class to differentiate)
jQuery.validator.addMethod("notEqualToGroup", function (value, element, options) {
// get all the elements passed here with the same class
var elems = $(element).parents('form').find(options[0]);
// the value of the current element
var valueToCompare = value;
// count
var matchesFound = 0;
// loop each element and compare its value with the current value
// and increase the count every time we find one
jQuery.each(elems, function () {