Jquery validator using date compare

Jquery validator using date compare

I am passing date in dd-mm-yyyy format to jquery validator function
 i have to compare two text box dates
first text box date in dd-mm-yyyy myst be less than second text box date dd-mm-yyyy.
This function is not giving proper output


 jQuery.validator.addMethod("greaterThan",
function(value, element, params) {

    if (!/Invalid|NaN/.test(new Date(value))) {
        return new Date(value) > new Date($(params).val());
    }

    return isNaN(value) && isNaN($(params).val())
        || (Number(value) > Number($(params).val()));
},'Must be greater than {0}.');