javascript - Alert message when there is duplicate email -


i need show alert message when there duplicate email address.

here code:

$.validator.addmethod("contactpersonen-email", function(value, element) {     var parentform = $(element).closest('form');     var timerepeated = 0;     if (value != '') {         $(parentform.find(':text')).each(function () {             if ($(this).val() === value) {                 timerepeated++;             }         });     }     return timerepeated === 1 || timerepeated === 0;     alert('duplicate'); }, "email adres bestaat al"); 

but doesn't work. find out problem , make working?

$.validator.addmethod("contactpersonen-email", function(value, element) {     var parentform = $(element).closest('form');     var timerepeated = 0;     if (value != '') {         $(parentform.find(':text')).each(function () {             if ($(this).val() === value) {                 timerepeated++;             }         });     }     var ok = timerepeated === 1 || timerepeated === 0;     if(!ok) alert('duplicate');     return ok; }, "email adres bestaat al"); 

Comments