简体   繁体   中英

Progress bar cant reset after submitting form using ajax

Hi Good afternoon please help me i have a problem in my progress bar. my progress bar wont reset after submitting the form and i used ajax for inserting data i want to reset my progress bar after triggering the submit button. i used the progress bar for password.here is my code in progress bar: my submit button name: "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>

The errors occurs in this condition:

$(this).val().length >= settings.minPasswordLength

But without a working snippet is difficult to say if it is failing the left or the right side of the condition. It seems it is always TRUE while you need it to be FALSE at certain point.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM