$(function () { $("#form-content-add").validate({ rules: { contract_no: { required: true, minlength: 1, maxlength: 45, remote: { url: pagePath + "/build/contract/isExistContractNo", type: "get", data: { contract_no: function () { return $("#contract_no").val(); }, id: "" } } }, company_phone: { isMobile: true }, paid_tenancy: { isFloat2: true }, paid_tenancy_month: { digits: true, }, deposit_fee: { isFloat2: true }, contract_start_date: { required: true, }, contract_end_date: { required: true, } }, messages: { contract_no: { remote: "该用合同号已被使用!" } }, onkeyup: false, focusCleanup: true, success: "valid", submitHandler: function (form) { if ($(".type:checked").length == 0) { errorMessage("至少选择一个模块"); return false; } $(form).ajaxSubmit({ type: 'post', url: pagePath + "/build/contract/save", dataType: "json", success: function (data) { if (data.status == "success") { succeedMessage(data.message); setTimeClose(); } else { errorMessage(data.message); } } }); return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。 }, errorPlacement: function (error, element) { if (element.attr('name') == 'buildLives[0].use_area' || element.attr('name') == 'buildLives[0].pay' || element.attr('name') == 'buildLives[0].build_number' || element.attr('name') == 'buildLives[0].floor' ) { error.addClass('label_error') } if (element.attr('name') == 'contractWaterList[0].name' || element.attr('name') == 'contractWaterList[0].start_water_meter_count') { error.addClass('label_error') } if (element.attr('name') == 'paid_tenancy' || element.attr('name') == 'paid_tenancy_month') { error.addClass('label_error') } if (element.attr('name') == 'contractElectrics[0].name' || element.attr('name') == 'contractElectrics[0].start_electric_meter_count') { error.addClass('label_error') } if (element.attr('name') == 'contractProperties[0].price' || element.attr('name') == 'contractProperties[0].number' || element.attr('name') == 'contractProperties[0].payment_cycle' ) { error.addClass('label_error') } if (element.attr('name') == 'contractParkings[0].price' || element.attr('name') == 'contractParkings[0].number' || element.attr('name') == 'contractParkings[0].payment_cycle' ) { error.addClass('label_error') } if (element.attr('name') == 'remind_day' || element.attr('name') == 'remind_day_number' || element.attr('name') == 'remind_day' ) { error.addClass('label_error') } if (element.attr('name') == 'tenancy_payment_cycle' || element.attr('name') == 'tenancy_payment_cycle_number' || element.attr('name') == 'tenancy_payment_cycle' ) { error.addClass('label_error') } error.appendTo(element.parent()); } }); }); function checkIsExistCompany() { $.ajax({ type: 'post', url: pagePath + "/build/contract/isExistCompanyName", dataType: "json", data: { company_name: function () { return $("#company_name").val(); } }, success: function (data) { if (data.success) { bindCompany(data.obj.company); } else { errorMessage(data.message); } } }); } function bindCompany(company) { $("input[name='company_id']").val(company.id); $("input[name='company_name']").val(company.company_name); $(".company_contact").children().remove(); if (company.companyContacts.length > 0) { for (var i=0;i*联系人:"; phoneLabel="*联系电话:"; } var html=""; html+="
"; html+=""; html+="
"; html+=""; html+="
"; html+=""; html+="
"; $(".company_contact").append(html); } } $("input[name='company_contact']").val(company.contact); $("input[name='company_phone']").val(company.phone); $("input[name='location']").val(company.location); } function contract_dialog(title, url, w, h) { layer_show(title, pagePath + url, w, h); }