<div class="content">
	<div class="page-index">
		<div class="card">
	<form action="index.php?c=race&action=race_reg_add&race_id=<?php echo $race_id; ?>&group_id=<?php echo $group_id;?>" method="post"
		  enctype="application/x-www-form-urlencoded">
		<table class="table">
			<tr>
				<td width="100">姓名</td>
				<td><input type="text" value="<?php echo $result[0]['realname'] ?>" name="realname" id="realname" placeholder="姓名" style="width:100%;">
				</td>
			</tr>
			<tr>
				<td>证件类型</td>
				<td>
					<select name="idcard_type"  id="idcard_type">
						<option value="1" <?php if($result[0]['idcard_type']==1){echo "selected";}?>>身份证</option>
						<option value="2" <?php if($result[0]['idcard_type']==2){echo "selected";}?>>军官证</option>
					</select>
					<option>
				</td> 
			</tr>
			<tr>
				<td>证件号码</td>
				<td>
					<input type="text" value="<?php echo $result[0]['idcard'] ?>" name="idcard" placeholder="证件号码" style="width:100%;" id="idcard">
				</td>
			</tr>
			<tr>
				<td>性别</td>
				<td>
					<select name="sex">
						<option value="1" <?php if($result[0]['sex']==1){echo "selected";}?>>男</option>
						<option value="2" <?php if($result[0]['sex']==2){echo "selected";}?>>女</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>出生日期</td>
				<td> 
				<input type="text" value="<?php echo $result[0]['born'] ?>" name="born" class="Wdate" onclick="WdatePicker()" placeholder="出生日期" id="born" style="height: 50px;">
					<input type="hidden" value="" name="age" id="age"/>
				</td>
			</tr>
			<tr>
				<td>手机号码</td>
				<td><input type="text" value="<?php echo $result[0]['tel'] ?>" name="tel" placeholder="手机号码" id="tel"></td>
			</tr>
			<tr>
				<td>联系邮箱</td>
				<td><input type="text" value="<?php echo $result[0]['email'] ?>" name="email" placeholder="联系邮箱"></td>
			</tr>
			<tr>
				<td>联系地址</td>
				<td><input type="text" value="<?php echo $result[0]['address'] ?>" name="address" placeholder="联系地址"></td>
			</tr>
			<tr>
				<?php if($p_update=='1')
				{?>
        <tr>
            <td align="center" colspan="2">
            请上传您参加过往北回归线上的足迹活动的，号码布、完赛证书或现场照片。
                <div id="cert_img_div">
                    <?php if ($result[0]['cert_img'])
                    {?>
                        <img src="<?php echo $result[0]['cert_img'] ?>" style="max-width: 200px"/>
                        <?php
                    }else{
                        ?>
                        <a onclick="setting('cert_img')" href="#" class="btn" style="width:100%; height:200px"> 
                       <br/><br/> <img src="images/upload.png" border="0">
                        </a>
                        <?php
                    }?>
                    <input type="hidden" value="<?php echo $result[0]['cert_img'] ?>" name="cert_img" id = "cert_img" >
                </div>
                <a onclick="setting('cert_img');" href="#" class="btn" style="padding:10px;background-color: orangered; color: white; text-align: center"> 图片上传 </a>
            </td>
        </tr>
		   <?php
		   }
		   echo $input_list; ?>
		</table>
	   <?php if($action !='my_reg_msg'){?>
		<input type="submit" value="提交报名" style="width: 98%; text-align:center;background-color: #00a0e9" class="btn" onclick="return check();">
		<br/><br/><br/><br/>
	</form>
<?php
}
else {
} ?>
</div>
</div>
</div>
<script language="JavaScript">
    function setting(id) {
        $("#frame_main").show();
        $("#f_i",parent.document.body).attr("src","plug-in/updateApi.php?image_id="+id)
    }

    function check()
    {
        realname = $("#realname").val();
        idcard= $("#idcard").val();
        born = $("#born").val();
        tel = $("#tel").val();
		cert_img= $("#cert_img").val();
        if(realname == "")
        {
            alert("请输入姓名");
            return false;
        }

        if(idcard=="")
        {
            alert("请输入身份证号码");
            return false;
        }
        //var idcarcheck=IdentityCodeValid(idcard);
        
        //if(!idcarcheck) {
           // return false;
        //}

        if(born == "")
        {
            alert("请输入出生日期");
            return false;
        }
        else
        {
			age= computeAge(born);
			<?php 
			if($s_age)
			{
			?>
			$("#age").val(age);
			if(age < <?php echo $s_age?> || age > <?php echo $b_age?>)
			{
				alert("对不起，本次活动要求<?php echo $s_age?>岁到<?php echo $b_age?>岁参加");
				return false;
			}
			<?php
			}
			?>
        }

        if(tel=="")
        {           
            alert("请填写手机号码");
            return false;
        }
        
        <?php if($p_update=='1')
				{?>
        if(cert_img == "")
        {
            alert("请上传图片");
            return false;
        }
        <?php } ?>
        if(!(/^1(3|4|5|7|8)\d{9}$/.test(tel))){
            alert("手机号码有误，请重填");
            return false;
        }
           
        return true;
    }
    
	function computeAge(startDate) 
	{
		// 获得今天的时间
		var date = new Date();
		startDate = new Date(startDate);
		var newDate = date.getTime() - startDate.getTime();
		// 向下取整  例如 10岁 20天 会计算成 10岁
		// 如果要向上取整 计算成11岁，把floor替换成 ceil
		return Math.floor(newDate / 1000 / 60 / 60 / 24 / 365);
	}
</script>
<style type="text/css">
    form input {width: 100%; padding: 10px; font-size: 12pt;}
    form select {padding: 10px;height:50px;}
</style>