简体   繁体   中英

Jquery Validation Engine displaying errors in alert

In validation engine I am attempting to get the errors to display inside of a javascript alert box instead of in a small tooltip next to them.

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

This is currently working to display that there is an error, but I'm trying to see if there's a way to list out the fields that have errors.

Thanks!

Assuming you are using this plugin.

This should do the trick for you:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM