2013-10-01 30 views
0

在驗證引擎中,我試圖讓錯誤顯示在JavaScript警告框內,而不是在旁邊的小工具提示中。Jquery驗證引擎在警報中顯示錯誤

$("#main_form").bind("jqv.form.result", function(event, errorFound) { 
    if(errorFound) 
     alert("There is a problem with your form.\n\nPlease fill out all of the required fields."); 
}); 

這是目前正在努力顯示有錯誤,但我想看看是否有一種方法,列出有錯誤的領域。

謝謝!

+0

什麼樣的jQuery驗證您使用的是? –

回答

0

假設您正在使用this插件。

這應該爲你做的伎倆:

var errors = []; // initialize the error array 

$('.formError').next().each(function(){ 
    errors.push($(this).attr('id')); 
}); 

console.log(errors); //Should give you an array of elements with errors.