$(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')
}
$this.after('')
} else{
$this.next().remove();
$this.addClass('noPass')
$this.after('不能为空')
}
})
$("#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')
}
$this.after('')
} else{
$('.noPassImg-bounce').remove();
$('.passImg').remove();
$("#getCode").css({'margin-left':'35px'})
$this.addClass('noPass')
$this.after('')
}
})
})
//计时
var countdown=60;
function addReceive(){
$("#receiverInfo").removeClass('hide');
}
function closeBounce(){
$(".bounces").addClass('hide');
}
// 获取验证码
function settime(val) {
var $val = $(val);
if (countdown == 60){
//异步发送验证码
$.ajax({
type: 'POST',
data: $('#register').serialize(),
dataType: "json",
url: '/user/getEmailCode',
success: function (data) {
if (data.success) {
} else {
}
}
});
}
if (countdown == 0) {
$('#getCode').removeClass('countBtn');
$('#getCode').addClass('bounceBtn');
val.removeAttribute("disabled");
$val.children().html("获取验证码")
countdown = 60;
} else {
$('#getCode').removeClass('bounceBtn');
$('#getCode').addClass('countBtn');
val.setAttribute("disabled", true);
$val.children().html("重新发送" + countdown + "s")
countdown--;
setTimeout(function() {
settime(val)
},1000)
}
}
function sure(){
var $newPwd = $("#newPwd").val();
var $pwda = $("#pwd-a").val();
if($pwda != $newPwd) {
$("#pwd-a").next().remove();
$("#pwd-a").addClass('noPass')
$("#pwd-a").after('输入不一致')
return;
}
$.ajax({
type: 'POST',
data: $('#register').serialize(),
dataType: "json",
url: '/user/register',
success: function (data) {
if (data.success) {
} else {
}
}
});
}