validation plug-in question-validating multiple conditional text fields

validation plug-in question-validating multiple conditional text fields

Sorry to bother you-I've been banging my head against this for too long.  I have the validation portion of code created like this:

                    $.validator.addClassRules({
                       hasDatepicker: {required:false, completionDatesNotSame:true}
                    });

The text fields have the DatePicker UI class attribute.  I added the custom method completionDatesNotSame
which basically checks all of the conditional text fields to verify that none of them match each other. 

 $.validator.addMethod("completionDatesNotSame", function() {
              var completionDates = $("input[id*='completionDate']:filled");

               if(completionDates.length > 1){
                  var dates = [];
                  completionDates.each( function(idx,val){ dates.push($(val).val()); } );
                  dates.sort();
                   // Check whether there are two equal values next to each other
                       for(var k = 1; k < dates.length; ++k ) {
                             if( dates[k] == dates[k-1] ) return false ;
                   }
                   return true;
                 }  else {
                  // only one field entered, nothing to compare
                    return true;

                 }

              }, "Please specify correct dates, no dates entered may be the same");




All of this works correctly, except for a problem with grouping.  Since I use the hasDatepicker class, it's creating the same error message for all (say three) fields, when only one error message should be displayed.  I'm not sure if there's a way in the validator.addClassRules function that I can say ignore when empty-or something similar.

I've also tried grouping like so:

groups: {
           hasDatepicker:"#messageBox"
  }

I would prefer not to try to manipulate the errorMap/errorList (I don't even know if that is possible anyway) to remove the extra matching messages.

Thanks!