/*
    JQuery.validate.js 表单验证插件 + JQuery.form.js + layer弹窗  
	公共表单验证和提交功能模块
	本代码由易网软件提供 
	网址：www.ew80.com   QQ:289669073  微信号：ew80net
*/



//为了避免发生验证地址变量获得错误，先进行变量判断和赋值。
if(chk_url_user=="" || chk_url_user==null ){	
var chk_url_user="Admin/userchk";	
}
if(chk_url_phone=="" || chk_url_phone==null ){	
var chk_url_phone="Admin/userchk";	
}
if(chk_url_email=="" || chk_url_email==null ){	
var chk_url_email="Admin/userchk";	
}
if(admin_chk == "" || admin_chk == null ){	
var admin_chk="Admin/chk";	
}

$(document).ready(function(){
	
	
//添加自定义验证规则
	//手机号验证
	jQuery.validator.addMethod("phone", function(value, element) { 
		var length = value.length; 
		var phone = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/ 
		return this.optional(element) || (length == 11 && phone.test(value)); 
	}, "手机号码格式错误"); 
	//邮编验证
	jQuery.validator.addMethod("code", function(value, element) { 
		var code = /^[0-9][6]$/ 
		return this.optional(element) || (code.test(value)); 
	}, "邮政编码格式错误"); 
		
		
	//公共参数配置	
	$.validator.setDefaults({
	
			
			
	 //重写showErrors
                showErrors: function (errorMap, errorList) {
                    var msg = "";
                    $.each(errorList, function (i, v) {
                        //msg += (v.message + "\r\n");
                        //在此处用了layer的方法,显示效果更美观
                        //layer.tip(v.message, v.element, {time: 2000 });
						layer.msg(v.message,{ icon:0,time: 2000 });
                        return false;
                    });  
                },
		 //空值检测开启，方便检测下拉框			
		ignore: "",	
		onkeyup : false,
		
});

//公共参数配置完成


    



	//后台新增用户表单验证
	$("#user_add").validate({
	
	submitHandler:function(form) {
	$(form).ajaxSubmit({
				
	beforeSubmit:function(formData, jqForm, options){
				//点击后，防止多次点击，将表单先禁用
				$('#ew80_submit').attr("disabled","disabled");
				layer.load();
				},
				
				success:function (responseText, statusText) {

					if(responseText){
						setTimeout(function(){
						layer.closeAll('loading');
						layer.msg(responseText,{ icon:1,time: 2000 });
						//完成后修改表单为可提交
						$('#ew80_submit').removeAttr("disabled");	
						$(form).resetForm();			
						},1000);				
					}	

					
				},
				//当有错误的情况下，提示错误原因
				error:function (event, errorText, errorType) {
				layer.closeAll('loading');
				layer.alert("操作失败，失败原因：<br>" + errorType, {icon: 0});
				$('#ew80_submit').removeAttr("disabled");	
				
					
			},
			
			});
		},
		//开始验证

		rules:{
			userid:{
				required:true,//必填
				minlength:3, //最少6个字符
				maxlength:32,//最多20个字符
				remote:chk_url_user,//用户名重复检查
			},
			phone:{
				required:true,
				phone:true,
				remote:chk_url_phone,//手机号重复检查
				
			},
			email:{
				email:true,
				remote:chk_url_email,//邮箱重复检查
				
			},
			uname:{
				required:true,	
			},
			
			pwd:{
				required:true,
				minlength:3, 
				maxlength:32,
			},
			pwd01:{
				
				required:true,
				minlength:3, 
				maxlength:32,	
				equalTo:'#pwd',
			},
			sid:{		
				required:true,
			},
			u_status:{	
				required:true,
			},
		},
		//错误信息提示
		messages:{
			userid:{
				required:"必须填写用户帐号",
				minlength:"用户帐号至少为3个字符",
				maxlength:"用户帐至多为32个字符",
				remote: "用户帐号已存在！",
			},
			phone:{
				required:"请填写用户手机号",
				phone:"手机号码格式错误",
				remote: "手机号已经存在！",
			},
			email:{
				email:"请填写正确的邮箱地址",
				remote: "邮箱已经存在！",
				
			},
			uname:{
				required:"请填写用户姓名",
				
			},
			pwd:{
				required:"必须填写密码",
				minlength:"密码至少为3个字符",
				maxlength:"密码至多为32个字符",
			},
			pwd01:{
				required:"必须填写密码",
				minlength:"密码至少为3个字符",
				maxlength:"密码至多为32个字符",
				equalTo:"二次填写的密码不相同",
			},
			sid:{	
			required:"请选择所属客服",		
			},
			u_status:{	
			required:"请选择用户类型",	
			},
			
		},

	});
	
    //后台会员新增END
	
	
	
	//修改会员基本资料验证
	$("#user_edit_1").validate({
	
	submitHandler:function(form) {
			$(form).ajaxSubmit({
				
				beforeSubmit:function(formData, jqForm, options){
				//点击后，防止多次点击，将表单先禁用
				$('#edit_sub').attr("disabled","disabled");
				layer.load();
				},
				
				success:function (responseText, statusText) {

					if(responseText){
						setTimeout(function(){
						layer.closeAll('loading');
						
						//完成后修改表单为可提交
						$('#edit_sub').removeAttr("disabled");	
						parent.$("#datatable-editable").load(window.parent.location.href+" #datatable-editable");});	
						layer.msg(responseText,{ icon:1,time: 2000 },function(){
						
						},1000);				
					}	

					
				},
				//当有错误的情况下，提示错误原因
				error:function (event, errorText, errorType) {
				layer.closeAll('loading');
				layer.alert("操作失败，失败原因：<br>" + errorType, {icon: 0});
				$('#edit_sub').removeAttr("disabled");	
				
					
			},
			
			});
		},
		//开始验证

		rules:{
			
			phone:{
				required:true,
				phone:true,
				remote:{
					type:'post',
					url:chk_url_phone,
					data:{id:function(){return $("#id").val();}} 
					},//手机号重复检查
				
			},
			email:{
				email:true,
				remote:{
					type:'post',
					url:chk_url_email,
					data:{id:function(){return $("#id").val();}}
					},//邮箱重复检查
				
			},
			
		},
		//错误信息提示
		messages:{
			
			phone:{
				required:"请填写用户手机号",
				phone:"手机号码格式错误",
				remote: "手机号已经存在！",
			},
			email:{
				email:"请填写正确的邮箱地址",
				remote: "邮箱已经存在！",
				
			},
			
		},

	});
	
    //修改会员基本资料验证END
	
	
	//修改会员密码
	$("#user_edit_2").validate({
	
	submitHandler:function(form) {
			$(form).ajaxSubmit({
				
				beforeSubmit:function(formData, jqForm, options){
				//点击后，防止多次点击，将表单先禁用
				$('#edit_sub').attr("disabled","disabled");
				layer.load();
				},
				
				success:function (responseText, statusText) {

					if(responseText){
						setTimeout(function(){
						layer.closeAll('loading');
						
						//完成后修改表单为可提交
						$('#edit_sub').removeAttr("disabled");	
						parent.$("#datatable-editable").load(window.parent.location.href+" #datatable-editable");});	
						layer.msg(responseText,{ icon:1,time: 2000 },function(){
						
						},1000);				
					}	

					
				},
				//当有错误的情况下，提示错误原因
				error:function (event, errorText, errorType) {
				layer.closeAll('loading');
				layer.alert("操作失败，失败原因：<br>" + errorType, {icon: 0});
				$('#edit_sub').removeAttr("disabled");	
				
					
			},
			
			});
		},
		//开始验证

		rules:{
			
			pwd:{
				required:true,
				minlength:3, 
				maxlength:32,
			},
			pwd01:{
				
				required:true,
				minlength:3, 
				maxlength:32,	
				equalTo:'#pwd',
			},
			
		},
		//错误信息提示
		messages:{
			
			pwd:{
				required:"如果需要修改密码，则需要填写密码",
				minlength:"密码至少为3个字符",
				maxlength:"密码至多为32个字符",
			},
			pwd01:{
				required:"必须填写密码",
				minlength:"密码至少为3个字符",
				maxlength:"密码至多为32个字符",
				equalTo:"二次填写的密码不相同",
			},
			
		},

	});
	
    //修改会员密码END
	
	//修改会员客服
	$("#user_edit_3").validate({
	
	submitHandler:function(form) {
			$(form).ajaxSubmit({
				
				beforeSubmit:function(formData, jqForm, options){
				//点击后，防止多次点击，将表单先禁用
				$('#edit_sub').attr("disabled","disabled");
				layer.load();
				},
				
				success:function (responseText, statusText) {

					if(responseText){
						setTimeout(function(){
						layer.closeAll('loading');
						
						//完成后修改表单为可提交
						$('#edit_sub').removeAttr("disabled");	
						parent.$("#datatable-editable").load(window.parent.location.href+" #datatable-editable");});	
						layer.msg(responseText,{ icon:1,time: 2000 },function(){
						
						},1000);				
					}	

					
				},
				//当有错误的情况下，提示错误原因
				error:function (event, errorText, errorType) {
				layer.closeAll('loading');
				layer.alert("操作失败，失败原因：<br>" + errorType, {icon: 0});
				$('#edit_sub').removeAttr("disabled");	
				
					
			},
			
			});
		},
		//开始验证

		rules:{
			
			sid:{
				required:true,
			},
			
		},
		//错误信息提示
		messages:{
			
			sid:{
				required:"请选择所属客服",

			},
			
		},

	});
	
    //修改会员所属客服END
	
	//修改会员联系方式
	$("#user_edit_4").validate({
	
	submitHandler:function(form) {
			$(form).ajaxSubmit({
				
				beforeSubmit:function(formData, jqForm, options){
				//点击后，防止多次点击，将表单先禁用
				$('#edit_sub').attr("disabled","disabled");
				layer.load();
				},
				
				success:function (responseText, statusText) {

					if(responseText){
						setTimeout(function(){
						layer.closeAll('loading');
						
						//完成后修改表单为可提交
						$('#edit_sub').removeAttr("disabled");	
						parent.$("#datatable-editable").load(window.parent.location.href+" #datatable-editable");});
						layer.msg(responseText,{ icon:1,time: 2000 },function(){
							
						},1000);				
					}	

					
				},
				//当有错误的情况下，提示错误原因
				error:function (event, errorText, errorType) {
				layer.closeAll('loading');
				layer.alert("操作失败，失败原因：<br>" + errorType, {icon: 0});
				$('#edit_sub').removeAttr("disabled");	
				
					
			},
			
			});
		},
		//开始验证

		rules:{
			
			uname:{
				required:true,
			},
			
		},
		//错误信息提示
		messages:{
			
			uname:{
				required:"请填写联系人",

			},
			
		},

	});
	
    //修改会员联系方式END
	
	
	
	
	
	
	
	//新增客服人员验证开始
	$("#service_add").validate({
	
	submitHandler:function(form) {
			$(form).ajaxSubmit({
				
				beforeSubmit:function(formData, jqForm, options){
				//点击后，防止多次点击，将表单先禁用
				$('#ew80_submit').attr("disabled","disabled");
				layer.load();
				},
				
				success:function (responseText, statusText) {

					if(responseText){
						setTimeout(function(){
						layer.closeAll('loading');
						layer.msg(responseText,{ icon:1,time: 2000 });
						//完成后修改表单为可提交
						$('#ew80_submit').removeAttr("disabled");	
						$(form).resetForm();			
						},1000);				
					}	

					
				},
				//当有错误的情况下，提示错误原因
				error:function (event, errorText, errorType) {
				layer.closeAll('loading');
				layer.alert("操作失败，失败原因：<br>" + errorType, {icon: 0});
				$('#ew80_submit').removeAttr("disabled");	
				
					
			},
			
			});
		},
		//开始验证

		rules:{
			userid:{
				required:true,//必填
				minlength:3, //最少6个字符
				maxlength:32,//最多20个字符
				remote:chk_url_user,//用户名重复检查
			},
			phone:{
				required:true,
				phone:true,
				remote:chk_url_phone,//手机号重复检查
				
			},
			email:{
				email:true,
				remote:chk_url_email,//邮箱重复检查
				
			},
			uname:{
				required:true,	
			},
			
			pwd:{
				required:true,
				minlength:3, 
				maxlength:32,
			},
			pwd01:{
				
				required:true,
				minlength:3, 
				maxlength:32,	
				equalTo:'#pwd',
			},
			
		},
		//错误信息提示
		messages:{
			userid:{
				required:"必须填写客服的登录帐号",
				minlength:"帐号至少为3个字符",
				maxlength:"帐至多为32个字符",
				remote: "已经存在相同帐号！",
			},
			phone:{
				required:"请填写用户手机号",
				phone:"手机号码格式错误",
				remote: "手机号已经存在！",
			},
			email:{
				email:"请填写正确的邮箱地址",
				remote: "邮箱已经存在！",
				
			},
			uname:{
				required:"请填写客服的姓名",
				
			},
			pwd:{
				required:"必须填写密码",
				minlength:"密码至少为3个字符",
				maxlength:"密码至多为32个字符",
			},
			pwd01:{
				required:"必须填写密码",
				minlength:"密码至少为3个字符",
				maxlength:"密码至多为32个字符",
				equalTo:"二次填写的密码不相同",
			},
			
			
		},

	});
	
    //客服人员新增验证结束
	
	
	//修改客服基本资料验证
	$("#kf_edit_1").validate({
	
	submitHandler:function(form) {
			$(form).ajaxSubmit({
				
				beforeSubmit:function(formData, jqForm, options){
				//点击后，防止多次点击，将表单先禁用
				$('#edit_sub').attr("disabled","disabled");
				layer.load();
				},
				
				success:function (responseText, statusText) {

					if(responseText){
						setTimeout(function(){
						layer.closeAll('loading');
						
						//完成后修改表单为可提交
						$('#edit_sub').removeAttr("disabled");	
						parent.$("#ew80_list_kf").load(window.parent.location.href+" #ew80_list_kf");});	
						layer.msg(responseText,{ icon:1,time: 2000 },function(){
						
						},1000);				
					}	

					
				},
				//当有错误的情况下，提示错误原因
				error:function (event, errorText, errorType) {
				layer.closeAll('loading');
				layer.alert("操作失败，失败原因：<br>" + errorType, {icon: 0});
				$('#edit_sub').removeAttr("disabled");	
				
					
			},
			
			});
		},
		//开始验证

		rules:{
			
			phone:{
				required:true,
				phone:true,
				remote:{
					type:'post',
					url:chk_url_phone,
					data:{id:function(){return $("#id").val();}} 
					},//手机号重复检查
				
			},
			email:{
				email:true,
				remote:{
					type:'post',
					url:chk_url_email,
					data:{id:function(){return $("#id").val();}}
					},//邮箱重复检查
				
			},
			
		},
		//错误信息提示
		messages:{
			
			phone:{
				required:"请填写用户手机号",
				phone:"手机号码格式错误",
				remote: "手机号已经存在！",
			},
			email:{
				email:"请填写正确的邮箱地址",
				remote: "邮箱已经存在！",
				
			},
			
		},

	});
	
    //修改客服基本资料验证END
	
	
	//修改客服密码
	$("#kf_edit_2").validate({
	
	submitHandler:function(form) {
			$(form).ajaxSubmit({
				
				beforeSubmit:function(formData, jqForm, options){
				//点击后，防止多次点击，将表单先禁用
				$('#edit_sub').attr("disabled","disabled");
				layer.load();
				},
				
				success:function (responseText, statusText) {

					if(responseText){
						setTimeout(function(){
						layer.closeAll('loading');
						
						//完成后修改表单为可提交
						$('#edit_sub').removeAttr("disabled");	
						parent.$("#ew80_list_kf").load(window.parent.location.href + " #ew80_list_kf");});	
						layer.msg(responseText,{ icon:1,time: 2000 },function(){
						
						},1000);				
					}	

					
				},
				//当有错误的情况下，提示错误原因
				error:function (event, errorText, errorType) {
				layer.closeAll('loading');
				layer.alert("操作失败，失败原因：<br>" + errorType, {icon: 0});
				$('#edit_sub').removeAttr("disabled");	
				
					
			},
			
			});
		},
		//开始验证

		rules:{
			
			pwd:{
				required:true,
				minlength:3, 
				maxlength:32,
			},
			pwd01:{
				
				required:true,
				minlength:3, 
				maxlength:32,	
				equalTo:'#pwd',
			},
			
		},
		//错误信息提示
		messages:{
			
			pwd:{
				required:"如果需要修改密码，则需要填写密码",
				minlength:"密码至少为3个字符",
				maxlength:"密码至多为32个字符",
			},
			pwd01:{
				required:"必须填写密码",
				minlength:"密码至少为3个字符",
				maxlength:"密码至多为32个字符",
				equalTo:"二次填写的密码不相同",
			},
			
		},

	});
	
    //修改客服密码END
	
	
	//修改客服密码
	$("#kf_edit_4").validate({
	
	submitHandler:function(form) {
			$(form).ajaxSubmit({
				
				beforeSubmit:function(formData, jqForm, options){
				//点击后，防止多次点击，将表单先禁用
				$('#edit_s4').attr("disabled","disabled");
				layer.load();
				},
				
				success:function (responseText, statusText) {

					if(responseText){
						setTimeout(function(){
						layer.closeAll('loading');
						
						//完成后修改表单为可提交
						$('#edit_s4').removeAttr("disabled");	
						parent.$("#ew80_list_kf").load(window.parent.location.href+" #ew80_list_kf");});	
						layer.msg(responseText,{ icon:1,time: 2000 },function(){
						
						},1000);				
					}	

					
				},
				//当有错误的情况下，提示错误原因
				error:function (event, errorText, errorType) {
				layer.closeAll('loading');
				layer.alert("操作失败，失败原因：<br>" + errorType, {icon: 0});
				$('#edit_s4').removeAttr("disabled");	
				
					
			},
			
			});
		},
		//开始验证

		rules:{
			
			cquyu:{
				required:true,
			},
			
		},
		//错误信息提示
		messages:{
			
			cquyu:{
				required:"请至少选择一项",
			},
			
		},

	});
	
    //修改客服分配END
	
	
	
	
	


});





//@@@  知识库 表单验证
//@@@  用于知识库栏目中的表单验证
//@@@  www.ew80.com  易网云工单系统

$(document).ready(function(){	

	$.validator.setDefaults({
		
	submitHandler:function(form) {
			$(form).ajaxSubmit({

				beforeSubmit:function(formData, jqForm, options){
				//点击后，防止多次点击，将表单先禁用
				$('#ew80_submit').attr("disabled","disabled");
				layer.load();
				},
				
				success:function (msg,statusText) {

					if(msg){
						setTimeout(function(){
						layer.closeAll('loading');
						parent.$("#ew80_list_warp").load(window.parent.location.href+" #ew80_list_warp");
						});	
						//完成后修改表单为可提交
						$('#ew80_submit').removeAttr("disabled");	
						layer.msg(msg['info'],{icon:msg['icon'],time:msg['times']},function(){
						
						},1000);				
					}	

					
				},
				//当有错误的情况下，提示错误原因
				error:function (event, errorText, errorType) {
				layer.closeAll('loading');
				layer.alert("操作失败，失败原因：<br>" + errorType, {icon: 0});
				$('#ew80_submit').removeAttr("disabled");	
				
					
			},
			
			});
		},	
		
	});
	
	
	//新增知识库文章验证
	$("#add_help_form").validate({
	
		//开始验证

		rules:{
			
			title:{required:true,},
			content:{required:true,},
	
		},
		//错误信息提示
		messages:{
			
			title:{required:"请填写文章标题",},
			content:{required:"请填写文章内容",},
		},

	});
	

	//新增文章分类验证
	$("#add_type_form").validate({
	
		//开始验证

		rules:{
			
			title:{required:true,},
	
		},
		//错误信息提示
		messages:{
			
			title:{required:"分类名称不能为空",},
	
		},

	});
	
		//修改文章分类验证
	$("#edit_type_form").validate({
	
		//开始验证

		rules:{
			
			title:{required:true,},
	
		},
		//错误信息提示
		messages:{
			
			title:{required:"分类名称不能为空",},
	
		},

	});


});





/////////////////// 系统配置相关表单验证

$(document).ready(function(){	

	$.validator.setDefaults({
		
	submitHandler:function(form) {
			$(form).ajaxSubmit({
				
				beforeSubmit:function(formData, jqForm, options){
				//点击后，防止多次点击，将表单先禁用
				$('#ew80_submit').attr("disabled","disabled");
				layer.load();
				},
				
				success:function (responseText, statusText) {

					if(responseText){
						setTimeout(function(){
						layer.closeAll('loading');
						
						//完成后修改表单为可提交
						$('#ew80_submit').removeAttr("disabled");	
						});	
						layer.msg(responseText,{ icon:1,time: 2000 },function(){
						
						},1000);				
					}	

					
				},
				//当有错误的情况下，提示错误原因
				error:function (event, errorText, errorType) {
				layer.closeAll('loading');
				layer.alert("操作失败，失败原因：<br>" + errorType, {icon: 0});
				$('#ew80_submit').removeAttr("disabled");	
				
					
			},
			
			});
		},	
		
	});
	
	
//系统参数配置
	$("#c_set_sys").validate({
	
	
		//开始验证

		rules:{
			
			soft_name:{required:true,},

			
		},
		//错误信息提示
		messages:{
			
			soft_name:{required:"系统名称不能为空哦",},
			
		},

	});
	
    //系统参数 结束		
	
//邮箱配置
	$("#c_set_email").validate({
	
	
		//开始验证

		rules:{
			
			mail_address:{
				required:true,
				email:true,

			},
			mail_smtp:{
				
				required:true,
			},
			mail_loginname:{required:true,},
			mail_password:{required:true,},
			mail_formname:{required:true,},
			
		},
		//错误信息提示
		messages:{
			
			mail_address:{
				required:"请填写邮箱地址",
				email:"邮箱格式不正确",
			},
			mail_smtp:{
				required:"请填写SMTP服务器地址",
			},
			mail_loginname:{required:"请填写邮箱用户名",},
			mail_password:{required:"请填写邮箱登录密码",},
			mail_formname:{required:"请填写发件人姓名",},
			
		},

	});
	
    //邮箱配置 结束	
	
	
	//短信配置
	$("#c_set_sms").validate({
	
	
		//开始验证

		rules:{
			
			phone_target:{
				required:true,

			},
			phone_user:{
				
				required:true,
			},
			phone_pass:{
				required:true,
				
			},

			
		},
		//错误信息提示
		messages:{
			
			phone_target:{
				required:"请填写短信接口地址",

			},
			phone_user:{
				
				required:"请填写短信帐号",
			},
			phone_pass:{
				required:"请填写短信密码",
				
			},

		},

	});
	
    //短信配置 结束	
	
	
	
	//时间配置
	$("#c_set_time").validate({
	
	
		//开始验证

		rules:{
			
			begin_time:{
				required:true,

			},
			end_time:{
				
				required:true,
			},
			begin_beputtime:{
				required:true,
				
			},
			end_beputtime:{
				
				required:true,
			},

			
		},
		//错误信息提示
		messages:{
			
			begin_time:{
				required:"请填写时间",

			},
			end_time:{
				
			required:"请填写时间",
			},
			begin_beputtime:{
				required:"请填写放假时间",
				
			},
			end_beputtime:{
				
			required:"请填写放假时间",
			},

		},

	});
	
    //时间配置 结束	
	

});



//@@@  管理和权限 表单验证
//@@@  用于管理和权限栏目中的表单验证
//@@@  www.ew80.com  易网云工单系统
	
	$(document).ready(function(){


		//新增管理员
	$("#add_admin_form").validate({
		
		submitHandler:function(form) {
			$(form).ajaxSubmit({
				
				beforeSubmit:function(formData, jqForm, options){
				//点击后，防止多次点击，将表单先禁用
				$('#ew80_submit').attr("disabled","disabled");
				layer.load();
				},
				
				success:function (responseText, statusText) {

					if(responseText){
						setTimeout(function(){
						layer.closeAll('loading');
						parent.$("#ew80_list_warp").load(window.parent.location.href+" #ew80_list_warp");});
						$(form).resetForm();
						//完成后修改表单为可提交
						$('#Auth_sub').removeAttr("disabled");	
						layer.msg(responseText,{ icon:1,time: 2000 },function(){		
						},1000);				
					}	

					
				},
				//当有错误的情况下，提示错误原因
				error:function (event, errorText, errorType) {
				layer.closeAll('loading');
				layer.alert("操作失败，失败原因：<br>" + errorType, {icon: 0});
				$('#ew80_submit').removeAttr("disabled");	
				
					
			},
			
			});
		},
		//开始验证
		
		
		//开始验证
		rules:{
			
			'group_ids[]':{
				required:true,//必填
			},
			
			username:{
				required:true,//必填
				minlength:3, //最少6个字符
				maxlength:32,//最多20个字符
				remote:admin_chk,//用户名重复检查
			},
			phone:{
				required:true,
				phone:true,
				remote:admin_chk,//手机号重复检查
				
			},
			email:{
				email:true,
				remote:admin_chk,//邮箱重复检查
				
			},
			admin_name:{
				required:true,
				minlength:2, //最少2个字符
				maxlength:5,//最多5个字符
				
			},
			password:{
				required:true,
				minlength:6, //最少6个字符
				maxlength:32,//最多32个字符
				
			},
			
		},
		//错误信息提示
		messages:{
			
			'group_ids[]':{	
			required:"请选择所属管理组",		
			},
			
			username:{
				required:"必须填写登陆帐号",
				minlength:"帐号至少为3个字符",
				maxlength:"帐号最多为32个字符",
				remote: "管理员帐号已存在！",
			},
			phone:{
				required:"请填写管理员手机号",
				phone:"手机号码格式错误",
				remote: "手机号已经存在！",
			},
			email:{
				email:"请填写正确的邮箱地址",
				remote: "邮箱已经存在！",
				
			},
			admin_name:{
				required:"管理员姓名没有填写",
				minlength:"姓名至少为2个字符",
				maxlength:"姓名最多为5个字符",
			},
			password:{
				required:"登陆密码没有填写",
				minlength:"密码至少为6个字符",
				maxlength:"密码最多为32个字符",
			},
			
		},
	}); 
	



	
	$.validator.setDefaults({
	submitHandler:function(form) {
			$(form).ajaxSubmit({
				
				beforeSubmit:function(formData, jqForm, options){
				
				//点击后，防止多次点击，将表单先禁用
				$('#Auth_sub').attr("disabled","disabled");
				layer.load();
				},
				
				success:function (responseText, statusText) {

					if(responseText){
						setTimeout(function(){
						layer.closeAll('loading');
						
						//完成后修改表单为可提交
						$('#Auth_sub').removeAttr("disabled");	
						parent.$("#ew80_list_warp").load(window.parent.location.href+" #ew80_list_warp");});
						layer.msg(responseText,{ icon:1,time: 2000 },function(){
								
						},1000);				
					}	

					
				},
				//当有错误的情况下，提示错误原因
				error:function (event, errorText, errorType) {
				layer.closeAll('loading');
				layer.alert("操作失败，失败原因：<br>" + errorType, {icon: 0});
				$('#Auth_sub').removeAttr("disabled");	
				
					
			},
			
			});
		},
	});
	
	
	
	//新增权限验证
	$("#add_rule_form").validate({
		//开始验证
		rules:{
			title:{
				required:true,
			},
			name:{
				required:true,
			},
		},
		//错误信息提示
		messages:{
			title:{
			required:"权限名必填",
			},
			name:{
			required:"权限值必填",
			},
		},
	}); 
	
	//修改权限验证
	$("#edit_rule_form").validate({
		//开始验证
		rules:{
			title:{
				required:true,
				
			},
			name:{
				required:true,
			},
		},
		//错误信息提示
		messages:{
			title:{
			required:"权限名必填",
			
			},
			name:{
			required:"权限值必填",
			},
		},
	});
	
	
	//新增用户组
	$("#add_group_form").validate({
		//开始验证
		rules:{
			title:{
				required:true,
			},
			
		},
		//错误信息提示
		messages:{
			title:{
			required:"请填写用户组名称",
			},
			
		},
	}); 
	
	//修改用户组
	$("#edit_group_form").validate({
		//开始验证
		rules:{
			title:{
				required:true,
			},
			
		},
		//错误信息提示
		messages:{
			title:{
			required:"请填写用户组名称",
			},
			
		},
	}); 
	
	//用户组权限分配
	$("#rule_group_form").validate({

	}); 
	

	
	//修改管理员资料
	
	$("#edit_admin_form").validate({
		

		//开始验证
		rules:{
			
			'group_ids[]':{
				required:true,//必填
			},
			
			username:{
				required:true,//必填
				minlength:3, //最少6个字符
				maxlength:32,//最多20个字符
				remote:{
					type:'post',
					url:admin_chk,
					data:{id:function(){return $("#id").val();}} 
					},
				
				
				
			},
			phone:{
				required:true,
				phone:true,
				remote:{
					type:'post',
					url:admin_chk,
					data:{id:function(){return $("#id").val();}} 
					},
				
			},
			email:{
				email:true,
				remote:{
					type:'post',
					url:admin_chk,
					data:{id:function(){return $("#id").val();}} 
					},
				
				
			},
			admin_name:{
				required:true,
				minlength:2, //最少2个字符
				maxlength:5,//最多5个字符
				
			},
			password:{
				minlength:6, //最少6个字符
				maxlength:32,//最多32个字符
				
			},
			
		},
		//错误信息提示
		messages:{
			
			'group_ids[]':{	
			required:"请选择所属管理组",		
			},
			
			username:{
				required:"必须填写登陆帐号",
				minlength:"帐号至少为3个字符",
				maxlength:"帐号最多为32个字符",
				remote: "管理员帐号已存在！",
			},
			phone:{
				required:"请填写管理员手机号",
				phone:"手机号码格式错误",
				remote: "手机号已经存在！",
			},
			email:{
				email:"请填写正确的邮箱地址",
				remote: "邮箱已经存在！",
				
			},
			admin_name:{
				required:"管理员姓名没有填写",
				minlength:"姓名至少为2个字符",
				maxlength:"姓名最多为5个字符",
			},
			password:{
				minlength:"密码至少为6个字符",
				maxlength:"密码最多为32个字符",
			},
			
		},
		

	}); 
	
	
	
});
	
//@@@  管理和权限表单验证结束
//@@@  ****************************
