Jquery validate验证结束日期大于开始日期


	jQuery.validator.methods.compareDate = function(value, element, param) { 
        //var startDate = jQuery(param).val() + ":00";补全yyyy-MM-dd HH:mm:ss格式 
        //value = value + ":00"; 
        var startDate = jQuery(param).val(); 
        var date1 = new Date(Date.parse(startDate.replace("-", "/"))); 
        var date2 = new Date(Date.parse(value.replace("-", "/"))); 
        return date1 < date2; 
    }; 
    jQuery.validator.methods.compareTime = function(value, element, param) { 
        //var startDate = jQuery(param).val() + ":00";补全yyyy-MM-dd HH:mm:ss格式 
        //value = value + ":00"; 
        var startDate = jQuery(param).val(); 
        var date1 = new Date(Date.parse(("2000-01-01 "+startDate).replace("-", "/"))); 
        var date2 = new Date(Date.parse(("2000-01-01 "+value).replace("-", "/"))); 
        return date1 < date2; 
    }; 

			buyEndDay : {
				required : true,
				compareDate : "#buyBeginDay",
			},
		messages : {
			buyEndDay : {
				compareDate : "结束日期必须大于开始日期"
			},
			useEndDay : {
				compareDate : "结束日期必须大于开始日期"
			},
			useEndTime : {
				compareTime : "结束时间必须大于开始时间"
			}
		}





你可能感兴趣的:(Jquery validate验证结束日期大于开始日期)