<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title><!--{$UUDEV_PAGE_TITLE}--></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--{include file=elements/header.css.html}-->
<!--{include file=elements/header.js.html type=common}-->
<!--{include file=elements/header.js.html type=valid}-->
</head>
<body>
<div id="outside">
	<!--{include file=frame/top.html}-->
	<div id="mainareaContent">
		<!--{include file=frame/left.html}-->
		<div id="rightContent">
			<div id="topContent">
				<div class="sitmap">
					<span class="r"><!--{include file="elements/uuadvad.html"}--></span>用户管理&nbsp;&gt;&nbsp;添加新用户
				</div>
			</div>
			<div class="tabcontent">
				<a href="index.php?r=User.userlist" class="nolink">会员列表</a>
				<a href="index.php?r=SiteSet.userset" class="link">属性设置</a>
				<a href="index.php?r=User.honourlist" class="link">会员头衔</a>
				<a href="index.php?r=SiteSet.experienceset" class="link">会员经验</a>
				<a href="index.php?r=User.forumroleimg" class="link">管理员身份勋章</a>
				<a href="index.php?r=User.albumlist" class="link">会员相册</a>
				<a href="index.php?r=User.listphotoframe" class="link">会员相框</a>
				<a href="index.php?r=User.msglist" class="link">会员消息</a>
				<a href="index.php?r=SiteSet.msgboxset" class="link">信箱设置</a>
			</div>
			<div id="secrightContent">
				<div class="tableContent">
					<form id="UserForm" action="index.php?r=User.add" method="post">
						<input type="hidden" name="returnParams" value="<!--{$returnParams}-->"/>
						<table class="tbl_edit" width="100%">
							<tr>
								<td class="td_name">用户ID<span class="red">*</span></td>							
								<td class="td_content"><input type="text" class="text" id="userid" name="data[User][id]"/><span id="span_userid"></span></td>
							</tr>
							<tr>
								<td class="td_name">后台登陆账号</td>
								<td class="td_content"><input type="text" class="text" id="login_name" name="data[User][login_name]"/><span id="span_login_name"></span></td>
							</tr>
							<tr>
								<td class="td_name">密码<span class="red">*</span></td>
								<td class="td_content"><input type="text" class="text" id="password" name="data[User][password]"/><span id="span_password"></span></td>
							</tr>
							<tr>
								<td class="td_name">昵称<span class="red">*</span></td>
								<td class="td_content"><input type="text" class="text" id="pet_name" name="data[User][pet_name]"/><span id="span_pet_name"></span></td>
							</tr>
							<tr>
								<td class="td_name">性别</td>
								<td class="td_content"><select name="data[User][gender]"><option value="1">男</option><option value="2">女</option></select></td>
							</tr>
							<tr>
								<td class="td_name">所在地区</td>
								<td class="td_content"><input type="text" class="text" name="data[User][area_name]"/></td>
							</tr>
							<tr>
								<td class="td_name">手机号码<span class="red">*</span></td>
								<td class="td_content"><input type="text" class="text" id="modile_phone_number" name="data[User][modile_phone_number]"/><span id="span_modile_phone_number"></span></td>
							</tr>
							<tr>
								<td class="td_name">QQ</td>
								<td class="td_content"><input type="text" class="text" id="qq" name="data[User][qq]"/><span id="span_qq"></span></td>
							</tr>
							<tr>
								<td class="td_name">身高</td>
								<td class="td_content"><input type="text" class="text" id="height" name="data[User][height]"/>&nbsp;&nbsp;cm<span id="span_height"></span></td>
							</tr>
							<tr>
								<td class="td_name">血型</td>
								<td class="td_content"><select name="data[User][blood_type]">
									<option value="1">请选择血型</option>
									<option value="2">A型</option>
									<option value="3">B型</option>
									<option value="4">O型</option>
									<option value="5">AB型</option>
									<option value="6">其它</option>
								</select></td>
							</tr>
							<tr>
								<td class="td_name">生日</td>
								<td class="td_content"><input type="text" class="text" id="birthday" name="data[User][birthday]"/><span id="span_birthday"></span></td>
							</tr>
							<tr>
								<td class="td_name">爱好</td>
								<td class="td_content"><input type="text" class="text" name="data[User][hobby]"/></td>
							</tr>
							<tr>
								<td class="td_name">职业</td>
								<td class="td_content"><input type="text" class="text" name="data[User][profession]"/></td>
							</tr>
							<tr>
								<td class="td_name">个人签名</td>
								<td class="td_content"><textarea class="textarea" name="data[User][forum_sign]"></textarea></td>
							</tr>
							<tr>
								<td class="noborder"></td>
								<td class="noborder"><button id= "formsubmit" type="submit" class="butsubmit">提交</button>&nbsp;&nbsp;<button type="button" class="but2font" onClick="window.location.href='index.php?<!--{$returnParams}-->'">返回</button></td>
							</tr>
						</table>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script>
$(document).ready(function(){
	jQuery.validator.addMethod("chrnum", function(value, element) {
    	return this.optional(element) || /^([a-zA-Z0-9]+)$/.test(value);
  	}, "必须由字母 或数字组成");
	$("#UserForm").validate({
		rules: {
			"data[User][password]": {
				required : true,
				chrnum : true,
				rangelength : [4, 16]
			},
			"data[User][modile_phone_number]":{
					required : true,
					digits : true,
					rangelength:[11,11],
					remote : {
						url: "index.php",
						cache: false,
						data: {
							r : "User.checkusermodilephonenumber",
							modile_phone_number : function(){
								return $("#modile_phone_number").val();
							}
						}
					}
			},
			
			"data[User][qq]":{
					required : false,
					digits : true
			},
			"data[User][height]":{
					required : false,
					digits : true,
					range :[0,300]
			},
			"data[User][birthday]":{
					required : false,
					digits : true,
					rangelength:[8,8]
			},
			"data[User][id]": {
				required : true,
				digits : true,
				remote : {
					url: "index.php",
					cache: false,					
					data: {
						r : "User.checkuserid",
						id : function(){
							return $("#userid").val();
						}
					}
				}
			},
			"data[User][pet_name]": {
				required : true,
				rangelength : [1, 16]
			}
		},	
		messages: {
			"data[User][password]": {
				required : "用户密码不能为空",
				rangelength : jQuery.format("密码长度必在{0}到{1}个字符之间")
			},
			"data[User][modile_phone_number]":{
				required:jQuery.format("手机号码不能为空"),
				digits : jQuery.format("不是正确的手机号码"),
				rangelength: jQuery.format("手机号码必须为{0}位数字"),
				remote : jQuery.format("手机号码{0}已存在")
			},
			
			"data[User][qq]":{
				digits : jQuery.format("QQ号码必须为数字")
			},
			"data[User][height]":{
				digits : jQuery.format("身高必须为数字"),
				range : jQuery.format("身高必须为{0}至{1}")
			},
			"data[User][birthday]":{
				digits : jQuery.format("生日必须为数字,例如：20101010"),
				rangelength:[8,8]
			},			
			"data[User][id]": {
				required : "用户ID不能为空",
				digits : jQuery.format("用户ID必须为数字"),
				remote : jQuery.format("用户ID{0}已存在")
			},
			"data[User][pet_name]": {
				required : "昵称不能为空",
				rangelength : jQuery.format("昵称长度必在{0}到{1}个字符之间")
			}
		},
		errorPlacement: function(error, element){
			$("#span_" + element.attr("id")).html(error).attr("class", "error");
		},
		submitHandler: function(form){
			setDisabled(":button",window.document);
			form.submit();
		},
		errorClass: "invalid",
		success: function(label){
			label.parent().html("&nbsp;").attr("class", "valid");
		},
		onkeyup: false
	});
	
	$("#login_name").blur(function(){
		var login_name = $(this).val();
		if(login_name!=""){
			$.ajax({
				type:'get',
				async:false,
				url:'index.php?r=User.checkLoginName'+"&rd="+Math.random(),
				data:{login_name:login_name},
				dataType:'json',
				success:function(data){
					if(data.status==1)
					{
						$("#formsubmit").attr("disabled","");
						$("#span_login_name").addClass("valid");
						$("#span_login_name").html('&nbsp;');
					}else{
						$("#span_login_name").addClass("error");
						$("#span_login_name").html('<label for="login_name" generated="true" class="invalid">后台登陆账号'+login_name+'已经存在</label>');
						$("#formsubmit").attr("disabled","disabled");
					}
				}
			});
		}else{
			$("#formsubmit").attr("disabled","");
			$("#span_login_name").html('');
			$("#span_login_name").removeClass("error");
		}
	});
});
</script>
</html>