$(function () { $("#form-dictionaryitem-edit").validate({ rules: { name: { required: true, minlength: 1, maxlength: 60, remote: { url: pagePath + "/super/isExistDictionaryItem", type: "get", data: { name: function () { return $("#name").val(); }, value: '', id: function () { return $("#id").val(); }, typeId: function () { return $("#typeId").val(); } } } }, value: { required: true, minlength: 1, maxlength: 60, remote: { url: pagePath + "/super/isExistDictionaryItem", type: "get", data: { name: '', value: function () { return $("#value").val(); }, id: function () { return $("#id").val(); }, typeId: function () { return $("#typeId").val(); } } } } }, messages: { name: { remote: "该数据类型条目已存在!" }, value: { remote: "该数据类型值已存在!" } }, onkeyup: false, focusCleanup: true, focusInvalid:false, success: "valid", submitHandler: function (form) { // $(form).find(":submit").attr("disabled", true); $(form).ajaxSubmit({ type: 'post', url: pagePath + "/super/dictionaryItem/save", dataType: "json", success: function (data) { if (data.success) { succeedMessage(data.message); setTimeClose(); } else { // $(form).find(":submit").attr("disabled", false); errorMessage(data.message); } }, error: function () { errorMessage('系统错误!'); } }); return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。 } }); });