Skip to content

Instantly share code, notes, and snippets.

@olsgreen
Created January 30, 2014 11:25
Show Gist options
  • Save olsgreen/8706692 to your computer and use it in GitHub Desktop.
Save olsgreen/8706692 to your computer and use it in GitHub Desktop.
jQuery Password Complexity Meter
/**
* jQuery Password Complexity Meter
*/
(function ($) {
$(document).ready(function () {
$('.check-complexity').complexify({minimumChars:6, strengthScaleFactor:0.3}, function(valid, complexity){
$('.password-complexity > .progress-bar').css('width', complexity + '%');
if(complexity < 70 && complexity > 40) {
$('.password-complexity > .progress-bar').removeClass('progress-bar-danger').removeClass('progress-bar-warning').addClass('progress-bar-warning');
} else if(complexity >= 70) {
$('.password-complexity > .progress-bar').removeClass('progress-bar-danger').removeClass('progress-bar-warning').addClass('progress-bar-success');
} else {
$('.password-complexity > .progress-bar').addClass('progress-bar-danger').removeClass('progress-bar-warning').addClass('progress-bar-success');
}
});
});
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment