Commit e9911288544152c0c347184697796296f1939cd1
1 parent
4d330bd5
修改密码检测插件
Showing
3 changed files
with
27 additions
and
2 deletions
src/main/resources/static/assets/plugins/passwordRulesHelper/passwordRulesHelper.js
| 1 | (function ($) { | 1 | (function ($) { |
| 2 | 2 | ||
| 3 | - $.fn.passwordRulesValidator = function (aOptions) { | 3 | + $.fn.passwordRulesValidator = function (aOptions, callbackFn) { |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | // Define default's parameters | 6 | // Define default's parameters |
| @@ -47,6 +47,22 @@ | @@ -47,6 +47,22 @@ | ||
| 47 | 'onLoad': undefined | 47 | 'onLoad': undefined |
| 48 | }; | 48 | }; |
| 49 | 49 | ||
| 50 | + var _ruleErrorMap = { | ||
| 51 | + }; | ||
| 52 | + function _callbackFn() { | ||
| 53 | + var isOk = false; | ||
| 54 | + $.each(_ruleErrorMap, function(k, v) { | ||
| 55 | + if (v) { | ||
| 56 | + isOk = true; | ||
| 57 | + } else { | ||
| 58 | + isOk = false; | ||
| 59 | + return false; | ||
| 60 | + } | ||
| 61 | + }); | ||
| 62 | + // console.log(_ruleErrorMap); | ||
| 63 | + callbackFn(isOk); | ||
| 64 | + } | ||
| 65 | + | ||
| 50 | /** | 66 | /** |
| 51 | * @param {object} oRegex | 67 | * @param {object} oRegex |
| 52 | * @param {string} sVal | 68 | * @param {string} sVal |
| @@ -57,8 +73,10 @@ | @@ -57,8 +73,10 @@ | ||
| 57 | { | 73 | { |
| 58 | if (oRegex.test(sVal)) { | 74 | if (oRegex.test(sVal)) { |
| 59 | $('#' + sIdContainer + ' li.' + sName).removeClass('ko ' + aParameters.koClass).addClass('ok ' + aParameters.okClass); | 75 | $('#' + sIdContainer + ' li.' + sName).removeClass('ko ' + aParameters.koClass).addClass('ok ' + aParameters.okClass); |
| 76 | + _ruleErrorMap[sName] = true; | ||
| 60 | } else { | 77 | } else { |
| 61 | $('#' + sIdContainer + ' li.' + sName).removeClass('ok ' +aParameters.okClass).addClass('ko ' +aParameters.koClass); | 78 | $('#' + sIdContainer + ' li.' + sName).removeClass('ok ' +aParameters.okClass).addClass('ko ' +aParameters.koClass); |
| 79 | + _ruleErrorMap[sName] = false; | ||
| 62 | } | 80 | } |
| 63 | } | 81 | } |
| 64 | 82 | ||
| @@ -112,18 +130,22 @@ | @@ -112,18 +130,22 @@ | ||
| 112 | 130 | ||
| 113 | // Execute checkRules on load | 131 | // Execute checkRules on load |
| 114 | checkRules(aParameters, $(this).val(), sIdContainer); | 132 | checkRules(aParameters, $(this).val(), sIdContainer); |
| 133 | + _callbackFn(); | ||
| 115 | 134 | ||
| 116 | // Execute checkRules fonction | 135 | // Execute checkRules fonction |
| 117 | $(this).keyup(function () { | 136 | $(this).keyup(function () { |
| 118 | checkRules(aParameters, $(this).val(), sIdContainer); | 137 | checkRules(aParameters, $(this).val(), sIdContainer); |
| 138 | + _callbackFn(); | ||
| 119 | }); | 139 | }); |
| 120 | 140 | ||
| 121 | $(this).on('paste', function () { | 141 | $(this).on('paste', function () { |
| 122 | checkRules(aParameters, $(this).val(), sIdContainer); | 142 | checkRules(aParameters, $(this).val(), sIdContainer); |
| 143 | + _callbackFn(); | ||
| 123 | }); | 144 | }); |
| 124 | 145 | ||
| 125 | $(this).change(function () { | 146 | $(this).change(function () { |
| 126 | checkRules(aParameters, $(this).val(), sIdContainer); | 147 | checkRules(aParameters, $(this).val(), sIdContainer); |
| 148 | + _callbackFn(); | ||
| 127 | }); | 149 | }); |
| 128 | }); | 150 | }); |
| 129 | }; | 151 | }; |
src/main/resources/static/index.html
| @@ -419,7 +419,7 @@ | @@ -419,7 +419,7 @@ | ||
| 419 | <!-- tipso JS --> | 419 | <!-- tipso JS --> |
| 420 | <script src="/metronic_v4.5.4/plugins/tipso/js/tipso.js"></script> | 420 | <script src="/metronic_v4.5.4/plugins/tipso/js/tipso.js"></script> |
| 421 | <!-- passwordRulesHelper插件 --> | 421 | <!-- passwordRulesHelper插件 --> |
| 422 | -<script src="/assets/plugins/passwordRulesHelper/passwordRulesHelper.min.js"></script> | 422 | +<script src="/assets/plugins/passwordRulesHelper/passwordRulesHelper.js"></script> |
| 423 | 423 | ||
| 424 | <script data-exclude=1> | 424 | <script data-exclude=1> |
| 425 | //初始打开的片段地址 | 425 | //初始打开的片段地址 |
src/main/resources/static/pages/permission/user/changePWD.html