I have a function in JavaScript that increments a password strength bar. It only goes of the strings length currently and i want it to increment more if it has unique characters in and a combination of upper and lower case characters.
Below is the current function which does work.
var bar = $('#progressbar div');
var password1 = $("#txtNewPassword");
var len = password1.val().length;
bar.css('width', len * 10 + '%');
if (len * 10 < 50)
{
bar.css('background', 'red');
}
else if(len * 10 > 50 && len * 10 < 100)
{
bar.css('background', 'orange');
}
else if (len * 10 >= 100)
{
bar.css('background', 'green');
$('#submitPC').removeAttr('disabled');
}
Also I have a submit button that is enabled and disabled when the strength is sufficient enough. I want that to enable the same as it does now but with the new additions. below is the add and remove attribute.
if (len * 10 < 100 || password != confirmPassword)
{
$('#submitPC').attr('disabled', 'disabled');
}
else
{
$('#submitPC').removeAttr('disabled');
}
I figured i would use a variable set within each conditional statement that would enable the submit dependent on strength rather than just the length like so.
if (blnStrength = true && password != confirmPassword)
{
$('#submitPC').attr('disabled', 'disabled');
}
else
{
$('#submitPC').removeAttr('disabled');
}
Now i want it to include special characters and never to get to 100% unless it contains at least 1 number upper case and lowercase character.
currently 1234567890
or abcdefghij
would be classed as a strong password when it is clearly not. below are a couple of example minimums I would want to be able to use.
at least 1 number Ucase or Lcase
Kieran12345 or something like K13r4NVen1s0N Should be secure