jQuery Validate - display one warning for the same types of errors

jQuery Validate - display one warning for the same types of errors

Hi,

I have a simple form that has several input elements that are required:

  1.     $("input").each(function(index, elem) {
  2.        var rules = {
  3.          required:true
  4.        }
  5.        $(elem).rules("add", rules);
  6.     });    

And I want to place all error messages within div:

  1.         <div id="errorContainer" class="inputGreska">
  2.             There are some errors. Please correct the following:
  3.             <ul id="errorLabelContainer"></ul>
  4.         </div>    

So, I did the following:

  1.         $("#forma").validate({
  2.            errorClass: "red",
  3.            errorContainer: "#errorContainer",
  4.            errorLabelContainer: "#errorLabelContainer",
  5.            wrapper: "li",
  6.            errorElement: "div"
  7.         });    

The problem is the following:

If the user forgets to fill more than one input - within error container there will be the same warnings repeated. So, if the user forgets to fill 3 fields, there will be:

  • This field is required.
  • This field is required.
  • This field is required.

Is it possible to show just one error message, like this:

  • Fields marked by asterisks (*) are required

 no matter how many elements the user has forgotten to fill.

Thank you.