<!DOCTYPE html>
<html lang=zh-cn> 
<head>
	<meta charset=utf-8> 
	<title>注册纵横通行帐号</title> 
	<meta name=description content=一个帐号通用纵横旗下所有网络产品。> 
	<meta name=copyright content=smartcost.com.cn> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel=stylesheet href={{rootUrl_CSS}}global.css>
	<script src={{rootUrl_JS}}jquery-1.7.1.min.js></script>
	<script src={{rootUrl_JS}}global.js></script>
	<script src={{rootUrl_JS}}jquery.validate.min.js></script>
	<script type="text/javascript">
		$(function(){
			jQuery.validator.addMethod("isMobile", function(value, element) {
				var length = value.length;
				var mobile = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1})|(14[0-9]{1}))+\d{8})$/;
				return this.optional(element) || (length == 11 && mobile.test(value));
			}, "请正确填写您的手机号码");

			$("#getpasswdbyphone").validate({
				rules: {
					zhmobile:{
						required: true,
						isMobile: true,
						remote: {
							url: '{{rootUrl}}checkphone',
							type: 'POST',
							dateType: 'json',
							data: {
								zhmobile: function () {
									return $('#zhmobile').val();
								}
							}
						}
					},
					zhsmscode: {
						required: true,
						isCode: true,
						remote: {
							url: '{{rootUrl}}check',
							type: 'POST',
							dateType: 'json',
							data: {
								zhsmscode: function () {
									return $('#zhsmscode').val();
								},
								zhmobile: function () {
									return $('#zhmobile').val();
								}
							}
						}
					}
				},
				messages: {
					zhmobile:{
						required: "请输入手机号",
						remote: "该手机号码未在纵横通行账号注册！"
					},
					zhsmscode: {
						required: "请输入验证码",
						remote: "验证码过期或不一致，请重新获取"
					}
				},
				errorElement: "span",// 错误信息容器标签
				errorClass: "textError",
				validClass: "inputSus",
				onkeyup: false
			})
		});
	</script>
</head>
<body>
<!--<h2 class="mobileTop">找回密码</h2>-->
<div class="mobileRe">
	<!-- <h3 class="mobileTopImg"><img src="images/mainlogo.png"></h3> -->
	<div class="trainFormItem">
		<div class="formEntry">
			<form method="post" name="getpasswdbyphone" id="getpasswdbyphone" action="/mobile/setpasswd">
			<dl class="regForm">
				<dt>请输入您的手机号码</dt>
				<dd>
					<input type="text" class="inputText" id="zhmobile" name="zhmobile" placeholder="请输入您的手机号码">
				</dd>
			</dl>
			<dl class="regForm codem" style="display: none">
				<dt>短信验证码</dt>
				<dd>
					<input type="text" class="inputText" name="zhsmscode" id="zhsmscode" style="width:45%;" placeholder="校验码是6位数字">
					<input type="button" class="btnTextMod btnTextOne" id="codebtn" name="codebtn" value="点击发送验证码" onclick="checkAndSend(this)" >
				</dd>
			</dl>
			<dl class="regForm" id="sendcode">
				<dd class="clearfix"><br><br><input class="button btn-green btnMobile" type="button" name="regmsubmit" value="点击发送验证码" onclick="checkAndSend($('#codebtn')[0])"><!-- if isset({{messages}}) --><p class="textError">{{messages}}</p><!-- endif --></dd>
			</dl>
			<dl class="regForm codem" style="display: none">
				<dd class="clearfix"><br><br><input class="button btn-green btnMobile" type="submit" id="regmsubmit" name="regmsubmit" value="设置新密码"></dd>
			</dl>
			</form>
		</div>
	</div>
</div>
<script type="text/javascript">
	var clock = '';
	var nums = 60;
	var btn;
	function checkAndSend(thisbtn){
		$('#zhmobile').removeClass('textError');
		if($('#zhmobile').siblings().hasClass('textError')){
			$('#zhmobile').siblings('.textError').remove();
		}
		var mobile = $('#zhmobile').val();
		if(mobile == ''){
			$('#zhmobile').addClass('textError');
			var span = '<span class="textError">请输入手机号</span>';
			$('#zhmobile').parent().append(span);
			return false;
		}else if(!mobile.match(/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1})|(14[0-9]{1}))+\d{8})$/)){
			$('#zhmobile').addClass('textError');
			var span = '<span class="textError">请正确填写您的手机号码</span>';
			$('#zhmobile').parent().append(span);
			return false;
		}
		var flag = true;
		$.ajax({
			url: '{{rootUrl}}checkgetpwdsms',
			type: 'POST',
			dateType: 'json',
			async: false,
			data: {zhmobile:mobile},
			success: function (result) {
				var data = eval('('+result+')');
				if(data.code == -1){
					$('#zhmobile').addClass('textError');
					var span = '<span class="textError">'+data.msg+'</span>';
					$('#zhmobile').parent().append(span);
					flag = false;
				}else if(data.code == 1){
					flag = true;
				}
			}
		});
		if(!flag){
			return false;
		}
		$('#zhmobile').addClass('inputSus');
		$('.codem').show();
		$('#sendcode').hide();
		sendCode(thisbtn);
	}

	function sendCode(thisBtn)
	{
		btn = thisBtn;
		btn.disabled = true; //将按钮置为不可点击
		btn.value = nums+'秒后可重新获取';
		$('#codebtn').removeClass('btnTextOne').addClass('btnText');
		clock = setInterval(doLoop, 1000); //一秒执行一次
	}
	function doLoop()
	{
		nums--;
		if(nums > 0){
			btn.value = nums+'秒后可重新获取';
		}else{
			clearInterval(clock); //清除js定时器
			btn.disabled = false;
			btn.value = '点击发送验证码';
			$('#codebtn').removeClass('btnText').addClass('btnTextOne');
			nums = 60; //重置时间
		}
	}
</script>
</body>