Это моя реализация при использовании плагина JQuery Validation и Colorbox. Что я делаю, так это то, что сначала я компилирую ошибки, а затем отображаю их один раз в Colorbox.
var error_list = '';
// submit button
jQuery("#continuebtn").click(function() {
error_list = '';
jQuery('#orderPageForm').attr('action', '/submitquote.html');
jQuery("#orderPageForm").submit();
});
jQuery(document).ready(function(){
// validate form
jQuery("#orderPageForm").validate ({
rules: {
width: { required: true, number: true, min: 1, max: 999 },
height: { required: true, number: true, min: 1, max: 999 },
folded_width: { required: true, number: true },
folded_height: { required: true, number: true },
stock: "required",
color: "required",
folding: "required",
quantity: { required: true, digit: true, min: 1, max: 100000 },
turnaround: "required"
},
messages: {
width: {
required: "Width is required.",
number: "Width value is not a number.",
min: "Minimum value for width is 1.",
max: "Maximum value for width is 999."
},
height: {
required: "Height is required",
number:"Height value is not a number.",
min: "Minimum value for height is 1.",
max: "Maximum value for height is 999."
},
folded_width: {
required: "Folded Width is required",
number:"Value is not a number."
},
folded_height: {
required: "Folded Height is required",
number:"Value is not a number."
},
stock: "Paper Type is required",
color: "Color is required",
folding: "Folding Type is required",
quantity: {
required: "Quantity is required",
number:"Quantity value is not a number.",
min: "Minimum value for quantity is 1.",
max: "Maximum value for quantity is 100000."
},
turnaround: "Turnaround is required"
},
errorPlacement: function(error, element) {
error_list += error.html() + '<br />';
jQuery("#error_popup").html(error_list);
parent.jQuery.colorbox({width:"400px", inline:true, href:"#error_popup"});
},
submitHandler: function(form) {
form.submit();
}
});
});