Forum Moderators: open
//Change password
function change_password() {
var themessage = "You are required to complete the following fields: \n";
if (document.form.current.value=="") {
themessage = themessage + " \n Current password";
}
if (document.form.new1.value=="") {
themessage = themessage + " \n New password";
}
if (document.form.new2.value=="") {
themessage = themessage + " \n New password (confirm)";
}
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: \n") {
document.form.submit();
}
else {
alert(themessage);
return false;
}
}
var updateStrength = function(pw) {
var strength = getStrength(pw);
var width = (100/32)*strength;
new Effect.Morph('psStrength', {style:'width:'+width+'px', duration:'0.4'});
}
var getStrength = function(passwd) {
intScore = 0;
if (passwd.match(/[a-z]/)) // [verified] at least one lower case letter
{
intScore = (intScore+1)
} if (passwd.match(/[A-Z]/)) // [verified] at least one upper case letter
{
intScore = (intScore+5)
} // NUMBERS
if (passwd.match(/\d+/)) // [verified] at least one number
{
intScore = (intScore+5)
} if (passwd.match(/(\d.*\d.*\d)/)) // [verified] at least three numbers
{
intScore = (intScore+5)
} // SPECIAL CHAR
if (passwd.match(/[!,@#$%^&*?_~]/)) // [verified] at least one special character
{
intScore = (intScore+5)
} if (passwd.match(/([!,@#$%^&*?_~].*[!,@#$%^&*?_~])/)) // [verified] at least two special characters
{
intScore = (intScore+5)
} // COMBOS
if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/)) // [verified] both upper and lower case
{
intScore = (intScore+2)
} if (passwd.match(/\d/) && passwd.match(/\D/)) // [verified] both letters and numbers
{
intScore = (intScore+2)
} // [Verified] Upper Letters, Lower Letters, numbers and special characters
if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/) && passwd.match(/\d/) && passwd.match(/[!,@#$%^&*?_~]/))
{
intScore = (intScore+2)
}
intScore = (intScore+passwd.length) // Add the length of the password to the score
if (intScore > 32)
{
intScore = 32
}
return intScore;
}
<p>
<label for="new1">New password: </label>
<input class="mf" name="new1" type="password" id="myinput" onKeyUp = "updateStrength(this.value)" value="" />
<span class="field_desc"></span><span class="validate_error">*</span>
</p>
<div id = "psContainer"><div id = "psStrength"></div></div>
<br><br>
</form>
<div id="button-left">
<a href="#" onClick="change_password();" alt="Confirm" title="Confirm" class="button"><span class="confirm">Confirm</a>
</div>