标签:sync lan hone ret blog 重试 存在 value script
<script type="text/javascript"> var validator; $(function() { $.validator.addMethod("compareDate", function(value, element) { var dateStart = $("#dateStart").val(); var dateEnd = $("#dateEnd").val(); return dateStart <= dateEnd; }, "开始日期必须早于结束日期"); $.validator.addMethod("checkMedicalExist", function(value, element) { var result = true; var address = $.trim($("#address").val()); var dateStart = $("#dateStart").val(); var dateEnd = $("#dateEnd").val(); if (address == ‘‘ || dateStart == ‘‘ || dateEnd == ‘‘) { return true; } $.ajax({ type : "POST", async : false, url : "${ctx}/meeting/medical/checkMedical", data : { "address" : address, "dateStart" : dateStart, "dateEnd" : dateEnd }, dataType : ‘json‘, success : function(d) { if (d.boolStatus == true) { var date = d.data; jBox.tip(date+‘已经存在医疗地点‘); result = false; } else { result = true; } } }); return result; }, "日期有冲突" ); $.validator.addMethod("compareTime", function(value, element) { var timeStart = $("#timeStart").val(); var timeEnd = $("#timeEnd").val(); return timeStart < timeEnd; }, "开始时间必须早于结束时间"); validator = $("#inputForm") .validate( { rules : { address : { required : true }, dateStart : { required : true }, dateEnd : { required : true, compareDate : true, checkMedicalExist : true }, timeStart : { required : true, }, timeEnd : { required : true, compareTime : true }, ambulanceNum : { required : true } /* name:{required:true}, phone:{required:true} */ }, submitHandler : function(form) { $ .ajax({ type : "POST", asyn : false, url : ‘${ctx}/meeting/medical/saveMedical‘, data : $(‘#inputForm‘) .serialize(),// 要提交的表单 dataType : ‘json‘, success : function(data) { if (data.status == ‘1‘) { //parent.jBox.tip(‘保存成功‘); window.parent.window.isFreshFlag=‘2‘;//刷新父页面 parent.$.jBox.close(); } else if (data.status == ‘0‘) { if(data.boolStatus == ‘true‘){ jBox.tip(‘日期:------重复‘); }else{ jBox.tip(‘保存失败,请重试‘); } } } }); } }); }) </script>
标签:sync lan hone ret blog 重试 存在 value script
原文地址:http://www.cnblogs.com/miye/p/7109518.html