1、git
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: "在當前產品中已存在" } },