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: "在当前产品中已存在"
                    }
                },
原文地址:https://www.cnblogs.com/eric-gms/p/7521086.html