userResgiter.js 2.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
$(function(){
	$(".write-n").blur(function(){
		var $this = $(this);
		var $value = $this.val();
		if ($value != "" && $value != null) {
			var isToggle = $this.attr('class').indexOf('noPass')>-1?true:false;
			if (isToggle) {
				$this.next().remove();
				$this.removeClass('noPass')
			}
爱吃血肠's avatar
爱吃血肠 已提交
11
			$this.after('<span class="passImg"><img src="/resource/img/pass.png"/></span>')
12 13 14
		} else{
			$this.next().remove();
			$this.addClass('noPass')
爱吃血肠's avatar
爱吃血肠 已提交
15
			$this.after('<span class="noPassImg-bounce"><img src="/resource/img/refuse.png"/>不能为空</span>')
16 17 18 19 20 21 22 23 24 25 26
		}
	})
	$("#code").blur(function(){
		var $this = $(this);
		var $value = $this.val();
		if ($value != "" && $value != null) {
			var isToggle = $this.attr('class').indexOf('noPass')>-1?true:false;
			if (isToggle) {
				$this.next().remove();
				$this.removeClass('noPass')
			}
爱吃血肠's avatar
爱吃血肠 已提交
27
			$this.after('<span class="passImg"><img src="/resource/img/pass.png"/></span>')
28 29 30 31 32
		} else{
			$('.noPassImg-bounce').remove();
			$('.passImg').remove();
			$("#getCode").css({'margin-left':'35px'})
			$this.addClass('noPass')
爱吃血肠's avatar
爱吃血肠 已提交
33
			$this.after('<span class="noPassImg-bounce"><img src="/resource/img/refuse.png"/></span>')
34 35 36 37 38 39 40 41 42 43 44
		}
	})
})
//计时
var countdown=60;
function addReceive(){
	$("#receiverInfo").removeClass('hide');
}
function closeBounce(){
	$(".bounces").addClass('hide');
}
爱吃血肠's avatar
爱吃血肠 已提交
45 46
// 获取验证码
function settime(val) {
47
	var $val = $(val);
爱吃血肠's avatar
爱吃血肠 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
	if (countdown == 60){
		//异步发送验证码
		$.ajax({
			type: 'POST',
			data: $('#register').serialize(),
			dataType: "json",
			url: '/user/getEmailCode',
			success: function (data) {
				if (data.success) {

				} else {

				}
			}
		});
	}
	if (countdown == 0) {
65 66
		$('#getCode').removeClass('countBtn');
		$('#getCode').addClass('bounceBtn');
爱吃血肠's avatar
爱吃血肠 已提交
67
		val.removeAttribute("disabled");
68
		$val.children().html("获取验证码")
爱吃血肠's avatar
爱吃血肠 已提交
69 70
		countdown = 60;
	} else {
71 72
		$('#getCode').removeClass('bounceBtn');
		$('#getCode').addClass('countBtn');
爱吃血肠's avatar
爱吃血肠 已提交
73
		val.setAttribute("disabled", true);
74
		$val.children().html("重新发送" + countdown + "s")
爱吃血肠's avatar
爱吃血肠 已提交
75 76 77 78 79 80
		countdown--;
		setTimeout(function() {
			settime(val)
		},1000)
	}
}
81 82 83 84 85 86
function sure(){
	var $newPwd = $("#newPwd").val();
	var $pwda = $("#pwd-a").val();
	if($pwda != $newPwd) {
		$("#pwd-a").next().remove();
		$("#pwd-a").addClass('noPass')
爱吃血肠's avatar
爱吃血肠 已提交
87 88
		$("#pwd-a").after('<span class="noPassImg-bounce"><img src="/resource/img/refuse.png"/>输入不一致</span>')
		return;
89
	}
爱吃血肠's avatar
爱吃血肠 已提交
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
		$.ajax({
			type: 'POST',
			data: $('#register').serialize(),
			dataType: "json",
			url: '/user/register',
			success: function (data) {
				if (data.success) {

				} else {

				}
			}
		});


105
}