Hi,
I'm just wondering how can I display both individual error messages and summary for the jquery plugin, I actually found a similar question but it just reference some hooks I can use, but I'm not sure where to start,
I got the displaying individual error messages part, but I need to display the summary in an alert box on submit, plugin can be found here
EDIT Just found out how, thanks for David's code, and on my follow up question - The alert box would be "First Name: Please enter a valid First Name".
Code below:
$(document).ready(function() {
var submitted = false;
('.selector').validate({
showErrors: function(errorMap, errorList) {
if (submitted) {
var summary = "You have the following errors: \n";
$.each(errorMap, function(key, value) {
summary += key + ': ' + value + "\n";
});
alert(summary);
submitted = false;
}
this.defaultShowErrors();
},
invalidHandler: function(form, validator) {
submitted = true;
}
});
});