嗨,下午好,请帮助我,我的进度条有问题。提交表格后我的进度条不会重置,我用过 用于插入数据的ajax我想在之后重置我的进度条 触发提交按钮。我使用进度条进行密码。我的代码在进度条中: 我的提交按钮名称:“insert-data
<script>
$(function() {
$.fn.bootstrapPasswordMeter = function(options) {
var settings = $.extend({
minPasswordLength: 1,
level0ClassName: 'progress-bar-danger',
level0Description: 'Weak',
level1ClassName: 'progress-bar-warning',
level1Description: 'Poor',
level2ClassName: 'progress-bar-info',
level2Description: 'Good',
level3ClassName: 'progress-bar-Primary',
level3Description: 'Strong',
level4ClassName: 'progress-bar-success',
level4Description: 'Very strong',
parentContainerClass: '.form-group'
}, options || {});
$(this).on("keyup", function() {
var progressBar = $(this).closest(settings.parentContainerClass).find('.progress-bar');
var progressBarWidth = 0;
var progressBarDescription = '';
if ($(this).val().length >= settings.minPasswordLength) {
var zxcvbnObj = zxcvbn($(this).val());
progressBar.removeClass(settings.level0ClassName)
.removeClass(settings.level1ClassName)
.removeClass(settings.level2ClassName)
.removeClass(settings.level3ClassName)
.removeClass(settings.level4ClassName)
switch (zxcvbnObj.score) {
case 0:
progressBarWidth = 0;
progressBar.addClass(settings.level0ClassName);
progressBarDescription = settings.level0Description;
break;
case 1:
progressBarWidth = 25;
progressBar.addClass(settings.level1ClassName);
progressBarDescription = settings.level1Description;
break;
case 2:
progressBarWidth = 50;
progressBar.addClass(settings.level2ClassName);
progressBarDescription = settings.level2Description;
break;
case 3:
progressBarWidth = 75;
progressBar.addClass(settings.level3ClassName);
progressBarDescription = settings.level3Description;
break;
case 4:
progressBarWidth = 100;
progressBar.addClass(settings.level4ClassName);
progressBarDescription = settings.level4Description;
break;
}
} else {
progressBarWidth = 0;
progressBarDescription = '';
}
progressBar.css('width', progressBarWidth + '%');
progressBar.text(progressBarDescription);
});
};
$('#Password').bootstrapPasswordMeter({
minPasswordLength: 3
});
});
});
</script>
答案 0 :(得分:0)
在这种情况下会发生错误:
$(this).val().length >= settings.minPasswordLength
但如果没有一个工作片段很难说它是否在条件的左侧或右侧失效。它似乎总是正确的,而你需要它在某一点上是假的。