3

我在我的 laravel 应用程序中使用了Jquery 表单验证器。但是密码验证和密码确认不起作用。控制台通过以下错误:-

jquery.form-validator.js:1276 未捕获的错误:使用未定义的验证器“validate_strength”。也许您忘记加载“validate_strength”所属的模块?

jquery.form-validator.js:1276 未捕获的错误:使用未定义的验证器“validate_confirmation”。也许您忘记加载“validate_confirmation”所属的模块?

以下是来自视图源的我的 HTML 代码

.....
<div class="form-group row required">
    <label for="password_confirmation" class="col-sm-2 control-label">Password</label>
    <div class="col-sm-10">
        <input placeholder="Enter Password" class="form-control" data-validation="strength" data-validation-strength="2" name="password_confirmation" type="password" value="" id="password_confirmation">
        <span style="color: #c9302c"></span>
     </div>
 </div>
 <div class="form-group row required">
     <label for="password" class="col-sm-2 control-label">Confirm Password</label>
     <div class="col-sm-10">
         <input placeholder="Re-enter Pasword" class="form-control" data-validation="confirmation" name="password" type="password" value="" id="password">
         <span style="color: #c9302c"></span>
      </div>
 </div>
 .....

和我的 js 代码

(function($, window) {
window.applyValidation = function(validateOnBlur, forms, messagePosition, xtraModule) {
    if( !forms )
        forms = 'form';
    $.validate({
        modules : 'security',
        form : forms,
        language : {
            requiredFields: 'Required Fields'
        },
        validateOnBlur : validateOnBlur,
        lang : 'en',
        onValidate : function($f) {
            var $callbackInput = $('#callback');
        },
        onModulesLoaded : function() {
            var optionalConfig = {
              fontSize: '12pt',
              padding: '4px',
              bad : 'Very bad',
              weak : 'Weak',
              good : 'Good',
              strong : 'Strong'
            };

            $('input[name="password_confirmation"]').displayPasswordStrength(optionalConfig);
        }
    });
};
window.applyValidation(true, '#candidate-signup', 'top');
})(jQuery, window);
4

0 回答 0