...
|
...
|
@@ -10,10 +10,6 @@ var $passwordInput = $('#pwd'), |
|
|
$repasswordInput = $('#re-input'),
|
|
|
$next = $('#reset-pwd-btn');
|
|
|
|
|
|
var EventProxy = require('yoho-eventproxy');
|
|
|
|
|
|
var ep = new EventProxy();
|
|
|
|
|
|
var pwdRegx = require('../common/mail-phone-regx').pwdValidateRegx;
|
|
|
|
|
|
function errTip(ele, msg) {
|
...
|
...
|
@@ -34,75 +30,65 @@ require('yoho-jquery-placeholder'); |
|
|
// IE8 placeholder
|
|
|
$('input').placeholder();
|
|
|
|
|
|
// 同时监听 pwd 和 repwd 事件
|
|
|
ep.tail('pwd', 'repwd', function(pwd, repwd) {
|
|
|
if (pwd && repwd) {
|
|
|
$next.removeClass('disable').prop('disabled', false);
|
|
|
} else {
|
|
|
$next.addClass('disable').prop('disabled', true);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$passwordInput.on('keyup blur', function() {
|
|
|
function validatePassword() {
|
|
|
var length = $passwordInput.val().length;
|
|
|
|
|
|
if (length === 0) {
|
|
|
errTip($passwordInput, '请输入密码');
|
|
|
ep.emit('pwd', false);
|
|
|
return;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (length < 6 || length > 20) {
|
|
|
errTip($passwordInput, '密码只支持 6-20 位字符,建议字母+数字的组合');
|
|
|
ep.emit('pwd', false);
|
|
|
return;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (!pwdRegx.test($passwordInput.val())) {
|
|
|
errTip($passwordInput, '密码只支持 6-20 位字符,建议字母+数字的组合');
|
|
|
ep.emit('pwd', false);
|
|
|
return;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
ep.emit('pwd', true);
|
|
|
hideTip($passwordInput);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
$passwordInput.on('blur', function() {
|
|
|
validatePassword();
|
|
|
}).on('focus', function() {
|
|
|
$passwordInput.addClass('focus');
|
|
|
hideTip($passwordInput);
|
|
|
}).on('blur', function() {
|
|
|
$passwordInput.removeClass('focus');
|
|
|
});
|
|
|
|
|
|
$repasswordInput.on('keyup blur', function() {
|
|
|
function validateRepassword() {
|
|
|
var length = $repasswordInput.val().length;
|
|
|
|
|
|
if (length === 0) {
|
|
|
errTip($repasswordInput, '请再次输入密码');
|
|
|
ep.emit('repwd', false);
|
|
|
return;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if ($passwordInput.val() !== $repasswordInput.val()) {
|
|
|
errTip($repasswordInput, '两次输入的密码不一致,请重新输入');
|
|
|
ep.emit('repwd', false);
|
|
|
return;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
ep.emit('repwd', true);
|
|
|
hideTip($repasswordInput);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
$repasswordInput.on('blur', function() {
|
|
|
validateRepassword();
|
|
|
}).on('focus', function() {
|
|
|
$repasswordInput.addClass('focus');
|
|
|
hideTip($repasswordInput);
|
|
|
}).on('blur', function() {
|
|
|
$repasswordInput.removeClass('focus');
|
|
|
});
|
|
|
|
|
|
// 监听 repwd 事件
|
|
|
ep.on('repwd', function(repwdAuth) {
|
|
|
if (repwdAuth) {
|
|
|
hideTip($repasswordInput);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 监听 pwd 事件
|
|
|
ep.on('pwd', function(pwdAuth) {
|
|
|
if (pwdAuth) {
|
|
|
hideTip($passwordInput);
|
|
|
$next.click(function() {
|
|
|
if (validatePassword() && validateRepassword()) {
|
|
|
$('#reset-pwd-form').submit();
|
|
|
}
|
|
|
}); |
...
|
...
|
|