2016-08-25 67 views
0

我希望對特定字段上的特定錯誤有不同的位置。 我嘗試的是下一個位置,但errorPlacement僅僅在第一次時才正確定位錯誤標籤並保持該位置,當驗證錯誤得到修復時使其內容爲空。 (所以它不會重新定位只有當先前從DOM手動刪除標籤錯誤)JQuery驗證器針對特定規則的特定錯誤的特定位置(errorPlacement不重新定位錯誤)

errorPlacement: function(error, element) { 
    if (error.text() == 'specific error from a specific rule') { 
    ///position error in the bottom off the form 
    } 
    else { 
    //position error in the default place as for all field errors 
    } 
}, 

回答

0

...正確定位錯誤標籤僅在第一次,並保持這個位置......

是的,這是因爲默認行爲是插入錯誤消息元素並將其切換爲所有後續錯誤。這就是插件的設計。