...
|
...
|
@@ -4,11 +4,13 @@ |
|
|
*/
|
|
|
|
|
|
var $ = require('yoho.jquery'),
|
|
|
regValidate = require('./mail-phone-regx');
|
|
|
regValidate = require('./mail-phone-regx'),
|
|
|
computeComplex = require('./pwd-strength');
|
|
|
|
|
|
var $registerPage = $('.register-page'),
|
|
|
$pwdTips = $('#pwd-tips'),
|
|
|
$errTip = $('#err-tip');
|
|
|
$errTip = $('#err-tip'),
|
|
|
$registerBtn = $('#register-btn');
|
|
|
|
|
|
var $sendCaptcha = $('#send-captcha'),
|
|
|
caCount = 4,
|
...
|
...
|
@@ -20,6 +22,10 @@ var $pn = $('#phone-num'), |
|
|
$repwd = $('#repwd'),
|
|
|
$ca = $('#captcha');
|
|
|
|
|
|
// 密码强度验证
|
|
|
var $pwdIntensity = $('.pwd-intensity'),
|
|
|
$pwdParent = $pwdIntensity.closest('.pwd-intensity-container');
|
|
|
|
|
|
//signup验证
|
|
|
var $region = $('#country-code'),
|
|
|
$regionSelect = $('#region');
|
...
|
...
|
@@ -293,20 +299,43 @@ function showBorder() { |
|
|
$errInput = $('#' + validateResult[i].id);
|
|
|
$errInput.addClass('error');
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//去掉红色边框
|
|
|
$errInput = $('#' + validateResult[i].id);
|
|
|
$errInput.removeClass('error');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 失去焦点时开始校验
|
|
|
$registerPage.find('.va').focus(function() {
|
|
|
// Tips: 不可以在获得焦点的时候验证,获得焦点和失去焦点的间隔太小,如果中间存在ajax校验的话会出现问题
|
|
|
$registerPage.find('.va').keyup(function() {
|
|
|
|
|
|
// 去掉错误提示,当获得焦点的时候重置message信息
|
|
|
var index = $(this).parents('li').attr('data-index');
|
|
|
var j,
|
|
|
statusLen = 0,
|
|
|
vLen = validateResult.length;
|
|
|
|
|
|
validateRule($(this), function() {
|
|
|
showErrTip();
|
|
|
showBorder(); // 显示红色边框
|
|
|
|
|
|
validateResult[index].message = '';
|
|
|
for (j = 0; j < vLen; j++) {
|
|
|
|
|
|
showErrTip(); // 显示错误提示
|
|
|
if (validateResult[j].status) {
|
|
|
|
|
|
statusLen++;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (statusLen === 4 && $('#agree-terms').is(':checked')) {
|
|
|
$registerBtn.removeClass('disable');
|
|
|
} else {
|
|
|
$registerBtn.addClass('disable');
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}).blur(function() {
|
|
|
|
...
|
...
|
@@ -338,4 +367,53 @@ $ca.keyup(function() { |
|
|
} else {
|
|
|
$sendCaptcha.addClass('disable');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$pwd.keyup(function() {
|
|
|
var pwd = $(this).val(),
|
|
|
pwdStrength = computeComplex(pwd),
|
|
|
level = 0;
|
|
|
|
|
|
if (pwdStrength === 0) {
|
|
|
level = 0;
|
|
|
} else if (pwdStrength <= 10) {
|
|
|
level = 1;
|
|
|
} else if (pwdStrength <= 20) {
|
|
|
level = 2;
|
|
|
} else {
|
|
|
level = 3;
|
|
|
}
|
|
|
|
|
|
switch (level) {
|
|
|
case 0:
|
|
|
$pwdParent.removeClass('red yellow green');
|
|
|
$pwdIntensity.removeClass('color');
|
|
|
break;
|
|
|
case 1:
|
|
|
$pwdParent.addClass('red').removeClass('yellow green');
|
|
|
$pwdIntensity.filter('.low').addClass('color');
|
|
|
$pwdIntensity.filter('.mid,.high').removeClass('color');
|
|
|
break;
|
|
|
case 2:
|
|
|
$pwdParent.addClass('yellow').removeClass('red green');
|
|
|
$pwdIntensity.filter('.low,.mid').addClass('color');
|
|
|
$pwdIntensity.filter('.high').removeClass('color');
|
|
|
break;
|
|
|
case 3:
|
|
|
$pwdParent.addClass('green').removeClass('yellow red');
|
|
|
$pwdIntensity.addClass('color');
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
//提示框
|
|
|
/*if (pwd === '') {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (pwd.length < 6 || pwd.length > 20) {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
}
|
|
|
}*/
|
|
|
}); |
|
|
\ No newline at end of file |
...
|
...
|
|