2013-09-23 128 views
1

我使用jQuery驗證和tooltipster顯示錯誤消息,它工作正常。不過,我想從窗體的頂部一次顯示一個錯誤消息。目前我收到每一個無效字段。jQuery驗證和Tooltipter一次顯示一個驗證消息

所以說,如果項目4剛剛被填寫,但項目3沒有被正確填寫,驗證信息顯示在3上,直到填寫正確。

這裏是我到目前爲止的代碼使用jquery validator with tooltip

$('#myform input[type="text"]').tooltipster({ 
       trigger: 'custom', 
       onlyOne: false, 
       position: 'top' 
      }); 


      $('#myform').validate({ 
       errorPlacement: function (error, element) { 

        $(element).tooltipster('update', $(error).text()); 
        $(element).tooltipster('show'); 
       }, 
       success: function (label, element) { 
        $(element).tooltipster('hide'); 
       }, 
       rules: { 
        EmailId: { 
         required: true, 
         email: true 
        }, 
        Password: { 
         required: true, 
         minlength: 5 

        }, 
        ComparePassword: { 
         required: true, 
         minlength: 5, 
         equalTo: "#Password" 

        }, 
        FirstName: { 
         required: true 
        }, 
        LastName: { 
         required: true 


       } 

       }, 

      }); 

任何幫助將非常感激。

回答

2

報價OP

「不過,我想在一個時間顯示一個錯誤消息」

也許你錯過了這個選項?

$('#myform input[type="text"]').tooltipster({ 
    trigger: 'custom', 
    onlyOne: false, // <-- THIS HERE 
    position: 'top' 
}); 

From the original answer

onlyOne: false, // allow multiple tips to be open at a time 
+0

十分感謝,我認爲選擇是隻顯示驗證消息後,我誤解。 – poperob

+0

完成。謝謝您的幫助。 – poperob