validate.js验证拓展

一、

jQuery.validator.methods.TemplateIDExists = function (value, element, param) {
//如果为编辑状态,则直接过
if (parseInt($("#OldProdcutID").val()) > 0) return true;
//如果为空,直接过
if (value.length == 0) return true;
var retVal = false;
//此处写自定义的请求
return retVal;
};
rules: {
                    TemplateID: {
                        min: 1,
                        max: 1000,
                        digits: true,
                        required: true,
                        TemplateIDExists: true
                    }
}
 messages: { // custom messages for radio buttons and checkboxes
                    TemplateID: {                        
                        TemplateIDExists: "在当前产品中已存在"
                    }
                },

 

posted on 2017-09-14 15:49  月&&生  阅读(187)  评论(0编辑  收藏  举报