I have used following jquery code
jQuery.validator.addMethod("unique", function(value, element, params) {
var prefix = params;
var selector = jQuery.validator.format("[name!='{0}'][name^='{1}'][unique='{1}']", element.name, prefix);
var matches = new Array();
$(selector).each(function(index, item) {
if (value == $(item).val()) {
matches.push(item);
}
});
return matches.length == 0;
}, "Value is not unique.");
jQuery.validator.classRuleSettings.unique = {
unique: true
};
$("#myform").validate();
$("#validate").click(function() {
$("#myform").valid();
});
but due to same input name its not working properly, check here https://jsfiddle.net/bgzBY/147/
but If I will use different name than that will work,check http://jsfiddle.net/mysteryh/bgzBY/
So how to fix it?