jQuery验证插件:验证自定义日期格式
答
jQuery.validator.addMethod("mydate", function(value, element) {
return this.optional(element) || /^\d\d?-\w\w\w-\d\d\d\d/.test(value);
}, "Please specify the date in DD-MMM-YYYY format");
答
看http://www.intelligrape.com/blog/2010/03/31/client-side-date-validation-using-jquery-plugins/
jQuery.validator.addMethod("customDateValidator", function(value, element) {
// parseDate throws exception if the value is invalid
try{jQuery.datepicker.parseDate('m/dd/yy', value);return true;}
catch(e){return false;}
},
"Please enter a valid date"
);
检查还引用后:Custom date format with jQuery validation plugin
另外:Validate two dates of this "dd-MMM-yyyy" format in javascript
使用jQuery验证插件[自定义日期格式可能重复在(http://*.com/questions/511439/custom-date-format-with-jquery-validation-plugin) – 2013-11-24 06:41:43