Hi,

Some question on the config of validation plugins.
Suppose there are #fromDate and #toDate fields (using ui.datepicker).
I have added these custom rules

                        jQuery.validator.addMethod("afterFromDate" 
,function(value,
element, targetId){
                                var fromDate = 
$("#"+targetId).datepicker("getDate");
                                var toDate = $(element).datepicker("getDate");
                                if(toDate && fromDate && fromDate > toDate){
                                        return false;
                                }
                                return true;
                        }, "Please input correct date range");
                        jQuery.validator.addMethod("beforeToDate" 
,function(value, element,
targetId){
                                var fromDate = $(element).datepicker("getDate");
                                var toDate = 
$("#"+targetId).datepicker("getDate");
                                if(toDate && fromDate && fromDate > toDate){
                                        return false;
                                }
                                return true;
                        }, "Please input correct date range");

And config like

$("#form").validate({
    rules:{
        'fromDate': { beforeToDate:'fromDate' },
        'toDate: { afterFromDate:'toDate' },
    }
})

It will output two messages of 'Please input correct date range'.
How can I make it only ouput single one?

Reply via email to