|
@@ -4,11 +4,13 @@ |
|
@@ -4,11 +4,13 @@ |
4
|
*/
|
4
|
*/
|
5
|
|
5
|
|
6
|
var $ = require('yoho.jquery'),
|
6
|
var $ = require('yoho.jquery'),
|
7
|
- regValidate = require('./mail-phone-regx');
|
7
|
+ regValidate = require('./mail-phone-regx'),
|
|
|
8
|
+ computeComplex = require('./pwd-strength');
|
8
|
|
9
|
|
9
|
var $registerPage = $('.register-page'),
|
10
|
var $registerPage = $('.register-page'),
|
10
|
$pwdTips = $('#pwd-tips'),
|
11
|
$pwdTips = $('#pwd-tips'),
|
11
|
- $errTip = $('#err-tip');
|
12
|
+ $errTip = $('#err-tip'),
|
|
|
13
|
+ $registerBtn = $('#register-btn');
|
12
|
|
14
|
|
13
|
var $sendCaptcha = $('#send-captcha'),
|
15
|
var $sendCaptcha = $('#send-captcha'),
|
14
|
caCount = 4,
|
16
|
caCount = 4,
|
|
@@ -20,6 +22,10 @@ var $pn = $('#phone-num'), |
|
@@ -20,6 +22,10 @@ var $pn = $('#phone-num'), |
20
|
$repwd = $('#repwd'),
|
22
|
$repwd = $('#repwd'),
|
21
|
$ca = $('#captcha');
|
23
|
$ca = $('#captcha');
|
22
|
|
24
|
|
|
|
25
|
+// 密码强度验证
|
|
|
26
|
+var $pwdIntensity = $('.pwd-intensity'),
|
|
|
27
|
+ $pwdParent = $pwdIntensity.closest('.pwd-intensity-container');
|
|
|
28
|
+
|
23
|
//signup验证
|
29
|
//signup验证
|
24
|
var $region = $('#country-code'),
|
30
|
var $region = $('#country-code'),
|
25
|
$regionSelect = $('#region');
|
31
|
$regionSelect = $('#region');
|
|
@@ -293,20 +299,43 @@ function showBorder() { |
|
@@ -293,20 +299,43 @@ function showBorder() { |
293
|
$errInput = $('#' + validateResult[i].id);
|
299
|
$errInput = $('#' + validateResult[i].id);
|
294
|
$errInput.addClass('error');
|
300
|
$errInput.addClass('error');
|
295
|
|
301
|
|
|
|
302
|
+ } else {
|
|
|
303
|
+
|
|
|
304
|
+ //去掉红色边框
|
|
|
305
|
+ $errInput = $('#' + validateResult[i].id);
|
|
|
306
|
+ $errInput.removeClass('error');
|
296
|
}
|
307
|
}
|
297
|
}
|
308
|
}
|
298
|
}
|
309
|
}
|
299
|
|
310
|
|
300
|
// 失去焦点时开始校验
|
311
|
// 失去焦点时开始校验
|
301
|
-$registerPage.find('.va').focus(function() {
|
312
|
+// Tips: 不可以在获得焦点的时候验证,获得焦点和失去焦点的间隔太小,如果中间存在ajax校验的话会出现问题
|
|
|
313
|
+$registerPage.find('.va').keyup(function() {
|
302
|
|
314
|
|
303
|
- // 去掉错误提示,当获得焦点的时候重置message信息
|
|
|
304
|
- var index = $(this).parents('li').attr('data-index');
|
315
|
+ var j,
|
|
|
316
|
+ statusLen = 0,
|
|
|
317
|
+ vLen = validateResult.length;
|
|
|
318
|
+
|
|
|
319
|
+ validateRule($(this), function() {
|
|
|
320
|
+ showErrTip();
|
|
|
321
|
+ showBorder(); // 显示红色边框
|
305
|
|
322
|
|
306
|
- validateResult[index].message = '';
|
323
|
+ for (j = 0; j < vLen; j++) {
|
307
|
|
324
|
|
308
|
- showErrTip(); // 显示错误提示
|
325
|
+ if (validateResult[j].status) {
|
|
|
326
|
+
|
|
|
327
|
+ statusLen++;
|
|
|
328
|
+ }
|
|
|
329
|
+
|
|
|
330
|
+ }
|
|
|
331
|
+
|
|
|
332
|
+ if (statusLen === 4 && $('#agree-terms').is(':checked')) {
|
|
|
333
|
+ $registerBtn.removeClass('disable');
|
|
|
334
|
+ } else {
|
|
|
335
|
+ $registerBtn.addClass('disable');
|
|
|
336
|
+ }
|
309
|
|
337
|
|
|
|
338
|
+ });
|
310
|
|
339
|
|
311
|
}).blur(function() {
|
340
|
}).blur(function() {
|
312
|
|
341
|
|
|
@@ -338,4 +367,53 @@ $ca.keyup(function() { |
|
@@ -338,4 +367,53 @@ $ca.keyup(function() { |
338
|
} else {
|
367
|
} else {
|
339
|
$sendCaptcha.addClass('disable');
|
368
|
$sendCaptcha.addClass('disable');
|
340
|
}
|
369
|
}
|
|
|
370
|
+});
|
|
|
371
|
+
|
|
|
372
|
+$pwd.keyup(function() {
|
|
|
373
|
+ var pwd = $(this).val(),
|
|
|
374
|
+ pwdStrength = computeComplex(pwd),
|
|
|
375
|
+ level = 0;
|
|
|
376
|
+
|
|
|
377
|
+ if (pwdStrength === 0) {
|
|
|
378
|
+ level = 0;
|
|
|
379
|
+ } else if (pwdStrength <= 10) {
|
|
|
380
|
+ level = 1;
|
|
|
381
|
+ } else if (pwdStrength <= 20) {
|
|
|
382
|
+ level = 2;
|
|
|
383
|
+ } else {
|
|
|
384
|
+ level = 3;
|
|
|
385
|
+ }
|
|
|
386
|
+
|
|
|
387
|
+ switch (level) {
|
|
|
388
|
+ case 0:
|
|
|
389
|
+ $pwdParent.removeClass('red yellow green');
|
|
|
390
|
+ $pwdIntensity.removeClass('color');
|
|
|
391
|
+ break;
|
|
|
392
|
+ case 1:
|
|
|
393
|
+ $pwdParent.addClass('red').removeClass('yellow green');
|
|
|
394
|
+ $pwdIntensity.filter('.low').addClass('color');
|
|
|
395
|
+ $pwdIntensity.filter('.mid,.high').removeClass('color');
|
|
|
396
|
+ break;
|
|
|
397
|
+ case 2:
|
|
|
398
|
+ $pwdParent.addClass('yellow').removeClass('red green');
|
|
|
399
|
+ $pwdIntensity.filter('.low,.mid').addClass('color');
|
|
|
400
|
+ $pwdIntensity.filter('.high').removeClass('color');
|
|
|
401
|
+ break;
|
|
|
402
|
+ case 3:
|
|
|
403
|
+ $pwdParent.addClass('green').removeClass('yellow red');
|
|
|
404
|
+ $pwdIntensity.addClass('color');
|
|
|
405
|
+ break;
|
|
|
406
|
+ }
|
|
|
407
|
+
|
|
|
408
|
+ //提示框
|
|
|
409
|
+ /*if (pwd === '') {
|
|
|
410
|
+
|
|
|
411
|
+ } else {
|
|
|
412
|
+
|
|
|
413
|
+ if (pwd.length < 6 || pwd.length > 20) {
|
|
|
414
|
+
|
|
|
415
|
+ } else {
|
|
|
416
|
+
|
|
|
417
|
+ }
|
|
|
418
|
+ }*/
|
341
|
}); |
419
|
}); |