|
446 | 446 | numRequiredLowercaseChars = $input.valAttr('require-lc-letter') || '0',
|
447 | 447 | numRequiredSpecialChars = $input.valAttr('require-special-char') || '0',
|
448 | 448 | numRequiredNumericChars = $input.valAttr('require-numeral') || '0',
|
| 449 | + numRequiredCharsTotal = $input.valAttr('require-length') || '0', |
449 | 450 | subValidators = {
|
450 | 451 | 'uc-letter': {
|
451 | 452 | pattern: '^(?=(?:.*[A-Z]){'+numRequiredUppercaseChars+',}).+',
|
|
466 | 467 | pattern: '^(?=(?:.*\\d){'+numRequiredNumericChars+',}).+',
|
467 | 468 | numRequired: numRequiredNumericChars,
|
468 | 469 | dialogEnd: $.formUtils.LANG.passwordComplexityNumericCharsInfo
|
| 470 | + }, |
| 471 | + 'length': { |
| 472 | + callback: function(val) { |
| 473 | + return val.length > numRequiredCharsTotal; |
| 474 | + }, |
| 475 | + numRequired: numRequiredCharsTotal, |
| 476 | + dialogEnd: 'Lorem te ipsum' |
469 | 477 | }
|
470 | 478 | },
|
471 | 479 | errorMessage = '';
|
472 | 480 |
|
473 | 481 | $.each(subValidators, function(name, subValidator) {
|
474 | 482 | var numRequired = parseInt(subValidator.numRequired, 10);
|
475 | 483 | if (numRequired) {
|
476 |
| - var regexp = new RegExp(subValidator.pattern); |
477 |
| - if (!regexp.test(value)) { |
| 484 | + var regexp = new RegExp(subValidator.pattern), |
| 485 | + valid = false; |
| 486 | + |
| 487 | + if (subValidator.callback) { |
| 488 | + valid = subValidator.callback(value); |
| 489 | + } else { |
| 490 | + valid = regexp.test(value); |
| 491 | + } |
| 492 | + |
| 493 | + if (!valid) { |
478 | 494 | if (errorMessage === '') {
|
479 | 495 | errorMessage = language.passwordComplexityStart;
|
480 | 496 | }
|
481 | 497 | errorMessage += language.passwordComplexitySeparator + numRequired + subValidator.dialogEnd;
|
482 |
| - $input.trigger('complexityValidation', [false, name]); |
| 498 | + $input.trigger('complexityRequirementValidation', [false, name]); |
483 | 499 | } else {
|
484 |
| - $input.trigger('complexityValidation', [true, name]); |
| 500 | + $input.trigger('complexityRequirementValidation', [true, name]); |
485 | 501 | }
|
486 | 502 | }
|
487 | 503 | });
|
488 |
| - |
489 | 504 | if (errorMessage) {
|
490 | 505 | this.errorMessage = errorMessage + language.passwordComplexityEnd;
|
491 | 506 | return false;
|
|
496 | 511 | errorMessage : '',
|
497 | 512 | errorMessageKey: ''
|
498 | 513 | });
|
499 |
| - |
| 514 | + |
500 | 515 | /*
|
501 | 516 | * Google reCaptcha 2
|
502 | 517 | */
|
|
0 commit comments