<form id="formAdd" method="post" action="?action=add">
<input type="hidden" name="dosubmit" value="1">
{?if $row.id>0?}<input type="hidden" name="id" value="{?$row.id?}">{?/if?}
<table width="100%" class="grid">
	<tr>
		<td class="tdleft" width="100"><span class="red">*</span> 管理员账号：</td>
		<td><input type="text" class="text" name="account" id="account" size="20" maxlength="20" value="{?$row.account?}" /></td>
	</tr>
	<tr>
		<td class="tdleft">{?if $row.id==0?}<span class="red">*</span> {?/if?}管理员密码：</td>
		<td><input type="password" class="text" name="password" id="password" size="20" maxlength="20" value="" /></td>
	</tr>
	<tr>
		<td class="tdleft">{?if $row.id==0?}<span class="red">*</span> {?/if?}确认密码：</td>
		<td><input type="password" class="text" name="repassword" id="repassword" size="20" maxlength="20" value="" /></td>
	</tr>
	<tr>
		<td class="tdleft">角色组：</td>
		<td>
			<select name="role">
				{?section name=i loop=$roles?}
				<option value="{?$roles[i].id?}"{?if $row.role==$roles[i].id?} selected{?/if?}>{?$roles[i].rolename?}</option>
				{?/section?}
			</select>
		</td>
	</tr>
	<tr>
		<td class="tdleft">管理员状态：</td>
		<td>
			<input type="radio" name="status" value="1"{?if $row.status=='1' || $row.status==''?} checked{?/if?}> 启用&nbsp;&nbsp; 
			<input type="radio" name="status" value="0"{?if $row.status=='0'?} checked{?/if?}> 禁用
		</td>
	</tr>
</table>
<div><input type="submit" name="submit" id="submit" class="button dodialog" value="提 交"/></div>
</form>
<script type="text/javascript">
$(function(){
	$.formValidator.initConfig({formid:"formAdd",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'250',height:'50'}, function(){this.close();$(obj).focus();})}});
	$("#account").formValidator({onshow:"请输入管理员账号",onfocus:"管理员账号应该为4-20位之间",oncorrect:"输入正确"}).inputValidator({min:4,max:20,onerror:"管理员账号应该为4-20位之间"}).regexValidator({regexp:"username",datatype:"enum",param:'i',onerror:"只能包括数字、字母、下划线三种类型。"});
	{?if $row.id>0?}
	$("#password").formValidator({empty:true,onshow:"不修改密码请留空",onfocus:"密码应该为6-20位之间",oncorrect:"输入正确"}).inputValidator({min:6,max:20,onerror:"密码应该为6-20位之间"});
	$("#repassword").formValidator({onshow:"不修改密码请留空",onfocus:"两次密码输入不同。",oncorrect:"密码输入一致"}).compareValidator({desid:"password",operateor:"=",onerror:"两次密码输入不同。"});
	{?else?}
	$("#password").formValidator({onshow:"请输入密码",onfocus:"密码应该为6-20位之间",oncorrect:"输入正确"}).inputValidator({min:6,max:20,onerror:"密码应该为6-20位之间"});
	$("#repassword").formValidator({onshow:"请输入确认密码",onfocus:"两次密码输入不同。",oncorrect:"密码输入一致"}).compareValidator({desid:"password",operateor:"=",onerror:"两次密码输入不同。"});
	{?/if?}
	$("#formAdd").ajaxForm({
        dataType: "json",
        success : function(data){
			if(data.flag == 0){
				doTip(data.msg);
			}else{
				window.top.mainframe.location.reload();
				doDialogClose();
			}
        }
    });
})
</script>