jQuery(document).ready(function() {
	$(".selector").val($("#userTypeId").val());
	$("#userInfoForm").validate({
		submitHandler : function(form) {
			$(form).ajaxSubmit({
				success : function(e) {
					if (e && e.success == true) {
						new $.zui.Messager('修改成功', {
							type : 'success'
						}).show();
						$("#myModal-updateUserInfo").modal('hide');
						
						$('.yk_head .info-username').text($('.info-usernameInput').val())
					} else {
						new $.zui.Messager('修改失败', {
							type : 'danger'
						}).show();
					}
				}
			});
		},
		rules : {
			'name' : {
				required : true,
				maxlength : 8
			},
			'password' : {
				rangelength : [ 6, 16 ],
				checkPassword : true
			},
			'mobile' : {
				required : true,
				checkPhone : true
			}
		},
		messages : {
			'name' : {
				required : "请输入姓名",
				maxlength : $.validator.format("最多只能输入{0}个字符")
			},
			'password' : {
				rangelength : "密码必须是6~16位数字和字母的组合"
			},
			'mobile' : {
				required : "请输入手机号",
				checkPhone : "请输入合法手机号"
			}
		}
	});

	// 自定义正则表达示验证方法
	$.validator.addMethod("checkPhone", function(value, element, params) {
		var checkPhone = /^1[34578]\d{9}$/;
		return this.optional(element) || (checkPhone.test(value));
	}, "手机号格式不正确");

	$.validator.addMethod("checkPassword", function(value, element, params) {
		var checkPassword = /^[0-9A-Za-z]{6,16}$/;
		return this.optional(element) || (checkPassword.test(value));
	}, "密码必须是6~16位数字和字母的组合");
});