Jquery.pwstrength密码强度指示符规则不起作用

时间:2016-05-08 09:15:40

标签: javascript jquery

我一直在尝试在我最近几天工作的项目中实施密码强度指标,并决定使用Jquery.pwstrength。

用户界面工作正常,两个规则正在运行,即wordSequenceswordRepetitions,但是其他规则都没有被强制执行,但都被激活并附加了分数。

这是我的代码:

$(document).ready(function() {
    options = {
        common: {
            minChar: 8,
            debug: true
        },
        ruleScores: {
            wordLength: -100,
            wordRepititions: -100,
            wordLowercase: 1,
            wordUppercase: 3,
            wordOneNumber: 3,
            wordThreeNumbers: 5,
            wordOneSpecialChar: 3,
            wordTwoSpecialChar: 5,
            wordUpperLowerCombo: 2,
            wordLetterNumberCombo: 2,
            wordLetterNumberCharCombo: 2
        },
        rules: {
            wordSequences: true,
            wordRepetitions: true,
            wordLength: true,
            wordLowercase: true,
            wordUppercase: true,
            wordOneNumber: true,
            wordThreeNumbers: true,
            wordOneSpecialChar: true,
            wordTwoSpecialChar: true,
            wordUpperLowerCombo: true,
            wordLetterNumberCombo: true,
            wordLetterNumberCharCombo: true
        },
        ui: {
            showPopover: true,
            showErrors: true,
            showProgressBar: true
        }
    };
    $('#password').pwstrength(options);
});

这是我正在使用指标的HTML页面:

<div class="form-group">
    <form:label path="password" class="col-sm-2 control-label required">Password:</form:label>
    <div class="col-sm-10">
        <c:if test="${not empty passwordRequired}">
            <form:input id="password" path="password" class="form-control" type="password" required="true" />
        </c:if>
        <c:if test="${empty passwordRequired}">
            <form:input id="password" path="password" class="form-control" type="password" />
        </c:if>
    </div>
</div>

知道这里发生了什么吗?我也在HTML中包含了正确的文件。

2 个答案:

答案 0 :(得分:1)

我刚刚开始使用它,所以我对此不太了解,但是我注意到在您的代码中,rulescores缺少“ wordSequences”,而rulecores和rules在“ wordRepititions”和“ wordRepetitions”中也有所不同

答案 1 :(得分:0)

如果不知道确切的包,很难确定(名称中有多个包含Jquery.pwstrength的包)。看起来您正在使用https://github.com/ablanco/jquery.pwstrength.bootstrap/blob/master/OPTIONS.md或类似内容,在这种情况下,您的options对象是错误的,它需要一个activated对象来保存rules