<!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">
<script type="text/javascript">
$().ready(function(){
	$("#addForm").validate({
		rules: {
			'data[MobileSerial][mobile_brand_id]' : 'required',
			'data[MobileSerial][serial]' : 'required',
			'data[MobileSerial][show_order]' : {
				'required' : true,
				'digits' : true,
				'range' : [1,999]
			}
		},
		messages: {
			'data[MobileSerial][mobile_brand_id]' : '请选择手机品牌',
			'data[MobileSerial][serial]' : '游戏系列不能为空',
			'data[MobileSerial][show_order]' : {
				'required' : '排列顺序不能为空',
				'digits' : '排列顺序必须为整数',
				'range' : '排列顺序必须在1-999之间'
			}
		},
		errorPlacement: function(error, element){
			$("#span_" + element.attr("id")).html(error).attr("class", "error");
		},
		submitHandler: function(form){
			var flag;
			$.ajax({url:"./index.php", 
					data:{r:"MobileSet.checkserial",
						  serial:$("#MobileSerial_serial").val(),
						  mobileBrandId:$("#MobileSerial_mobile_brand_id").val()
						  },
					cache:false,
					async:false,
					type:"GET",
					success:function(datastr){
					   	flag = datastr;
					}
			});
			if(flag == "false"){
				$("#span_MobileSerial_serial").html("系列" + $("#MobileSerial_serial").val() +"已存在，请重新输入").attr("class", "error");
				return;
			}
			setDisabled(":button",window.document);
			form.submit();
		},
		errorClass: "invalid",
		success: function(label){
			label.parent().html("&nbsp;").attr("class", "valid");
		}
	});
});
</script>
</head>
<body>
<form action="index.php?r=MobileSet.addserial" method="post" id="addForm">
	<table class="tbl_edit" width="100%">
	<tr>
		<td class="td_name">手机品牌<span class="red">*</span></td>
		<td class="td_content">
			<select name="data[MobileSerial][mobile_brand_id]" id="MobileSerial_mobile_brand_id">
			<option value="">--请选择手机品牌--</option>
			<!--{foreach from=$brands item=brand}-->
				<option value="<!--{$brand.id}-->"><!--{$brand.brand_name}--></option>
			<!--{/foreach}-->
			</select><span id="span_MobileSerial_mobile_brand_id"></span>
		</td>
	</tr><tr>
		<td class="td_name">游戏系列<span class="red">*</span></td>
		<td class="td_content">
			<input type="text" name="data[MobileSerial][serial]" id="MobileSerial_serial" class="text" maxlength='30'/><span id="span_MobileSerial_serial"></span>
		</td>
	</tr><tr>
		<td class="td_name">排列顺序<span class="red">*</span></td>
		<td class="td_content">
			<input type="text" name="data[MobileSerial][show_order]" id="MobileSerial_show_order" class="text" value="999" maxlength='3'/><span id="span_MobileSerial_show_order"></span>
		</td>
	</tr><tr>
		<td class="noborder"></td>
		<td class="noborder"><button type="submit" class="butsubmit">提交</button></td>
	</tr>
</table>
</form>
</body>
</html>