122 js 关闭子窗口刷新夫窗口 validate新增规则 新增比较时间规则

来源:互联网 发布:js字符串格式化时间 编辑:程序博客网 时间:2024/05/22 08:26

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  ;    },"结束日期必须大于开始日期!");


1 0
原创粉丝点击