validate不用submit按钮点击触发,如何提交表单

 



function pushOrSave(status){

		if($("#disciplinaryForm").valid()){
			 
		     $("#disciplinaryForm").submit();
	    }
	}
		/*表单校验*/
		$("#disciplinaryForm").validate({
			
	        rules: {
	        	name: {required:true},
	        	businessArea: {required:true},
	        	type :{required:true}, 
	        	
	        	unitName:{required:true},
	        	officeName:{required:true},
	        	
	        	advice:{required:true},
	        	linkMan:{required:true},
	        	linkTel:{required:true}
	        	
	        },
	        messages: {
	        	name : {  
	                required: "名单名称不能为空"
	            },
	            businessArea : {
	            	required: "业务领域不能为空"
	            },
	            type : {  
	                required: "名单类别不能为空"
	            },
	            
	            unitName:{
	            	required: "认定单位不能为空"
	            },
	            officeName:{
	            	required: "处室不能为空"
	            },
	            
	            advice:{
	            	required: "惩戒建议不能为空"
	            },
	            linkMan:{
	            	required: "认定单位负责人不能为空"
	            },
	            linkTel:{
	            	required: "联系电话不能为空"
	            }
	        },
	        /* 重写错误显示消息方法,以layer方式浮动错误消息 */  
	        showErrors: function(errorMap, errorList) {
	            var msg = "";
	            $.each(errorList, function(i,v){
					layer.tips(v.message, v.element, {
						tips: [1, '#FF6666'],
						time: 1000
					});
					return false;
	            });
	        }

	        
	       
	    });

		
        

		var advice=$("#advice").val();
		if(advice=='3'){
			$("#adviceContent").rules("add", {
			       required: true,
			       messages: {
			         required: "其他建议备注不能为空"
			       }
			 }); 
		}
		
		var basisFile=$("#basisFile").val();
		if(basisFile==''){
			$("#basis").rules("add", {
			       required: true,
			       messages: {
			         required: "认定依据不能为空"
			       }
			 }); 
		}
	
		var reportFile=$("#reportFile").val();
		if(reportFile==''){
			$("#report").rules("add", {
			       required: true,
			       messages: {
			         required: "报送函不能为空"
			       }
			 }); 
		}

 

你可能感兴趣的:(validate不用submit按钮点击触发,如何提交表单)