添加了后续验证方法
// jquery validation method to validate date format
jQuery.validator.addMethod("DateFormat", function(value, element) {
var date_regex = /^(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])\/(19|20)\d{2}$/ ;
var comp = value.split('/');
var m = parseInt(comp[0], 10);
var d = parseInt(comp[1], 10);
var y = parseInt(comp[2], 10);
var date = new Date(y,m,d);
return this.optional(element) || (date_regex.test(value) && date.getFullYear() == y && date.getMonth() == m && date.getDate() == d);
});
//jquery validation method to validate date range
jQuery.validator.addMethod("DateToFrom", function(value, element, arg0, arg1) {
var comp = value.split('/');
var m = parseInt(comp[0], 10);
var d = parseInt(comp[1], 10);
var y = parseInt(comp[2], 10);
var currentEltdate = new Date(y,m,d);
comp = $("#"+arg0).val().split('/');
m = parseInt(comp[0], 10);
d = parseInt(comp[1], 10);
y = parseInt(comp[2], 10);
var otherEltDate = new Date(y,m,d);
var lowerDate, upperDate;
if(arg1 == true){//current element should be lower date
lowerDate = currentEltdate;
upperDate = otherEltDate;
}else{
lowerDate = otherEltDate;
upperDate = currentEltdate;
}
return this.optional(element) || (lowerDate <= upperDate);
});
// jquery validation method to validate date range
jQuery.validator.addMethod("DateRange", function(value, element, arg0, arg1) {
var comp = arg0.split('/');
var m = parseInt(comp[0], 10);
var d = parseInt(comp[1], 10);
var y = parseInt(comp[2], 10);
var startDate = new Date(y,m,d);
comp = arg1.split('/');
m = parseInt(comp[0], 10);
d = parseInt(comp[1], 10);
y = parseInt(comp[2], 10);
var endDate = new Date(y,m,d);
comp = value.split('/');
m = parseInt(comp[0], 10);
d = parseInt(comp[1], 10);
y = parseInt(comp[2], 10);
var date = new Date(y,m,d);
return this.optional(element) || ((startDate <= date) && (date <= endDate));
});