2016-05-09 9 views
0

重複する電子メールアドレスがある場合は、警告メッセージを表示する必要があります。電子メールが重複している場合の警告メッセージ

は、ここに私のコードです:

$.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"); 

しかし、それは動作しません。問題を見つけてそれを機能させることができますか?

+3

return文の後で警告する場合は、 –

+0

の前に入力してください。html plsを提供できますか? –

+1

実行または呼び出しに到達できないreturn文の後に警告メッセージを配置しました。 – Srinu

答えて

1
$.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"); 
+0

こんにちは。ありがとうございました!!非常に素晴らしい – InfinityGoesAround

関連する問題