background: jquery.validate 插件中 submitHandler
submitHandler:function(form){
$('#theForm').ajaxSubmit(function(data, result){
if( result == 'success' ){
var obj = eval("("+data+")");
pageOverLay("#pageOverlay");
if( obj.status == 1 ){
coolHint(obj.info, function(){
window.parent.location.reload();
window.frameElement.trigger('close');
}, '2px', '240px');
}else{
coolHint(obj.info, function(){
window.parent.location.reload();
window.frameElement.trigger('close');
}, '2px', '240px');
}
}else{
alert("提交失败!可能是网络问题");
}
});
}
validate插件新增规则
jQuery.validator.addMethod("positiveinteger", function(value, element) {
var aint=parseInt(value);
return aint>0&& (aint+"")==value;
}, "Please enter a valid number.");
//校验
$("#theForm").validate({
rules: {
days:{ positiveinteger:true}
},
messages: {
days:{
positiveinteger:"请输入正整数"
},
新增比较时间规则
jQuery.validator.addMethod("endDate",
function(value, element) {
var startDate = $("input[name='startdate']").val();
return new Date(Date.parse(startDate.replace("-", "/"))) <= new Date(Date.parse(value.replace("-", "/"))) && value ;
},"结束日期必须大于开始日期!");