var passwordMeter = {
isValid: function (passwd1, passwdCmt1, passwd2, passwdCmt2)
{
this.p1 = document.getElementById(passwd1);
this.c1 = document.getElementById(passwdCmt1);
this.c1c = this.c1;
this.p2 = document.getElementById(passwd2);
this.c2 = document.getElementById(passwdCmt2);
this.imgOK = '
';
this.imgFAIL = '
';
this.msgtrue = MSG_PWCORRECT;
var valid = true;
var msg = '';
if (this.c1.getElementsByTagName('span')[0])
this.c1c = this.c1.getElementsByTagName('span')[0];
if (this.p1.value == '')
{
msg = '';
valid = false;
}
else if (this.p1.value.length < 6)
{
msg = MSG_PWLENGHT;
valid = false;
}
else
{
if (!this.p1.value.match(/[0-9]+/))
{
msg += MSG_PWDIGIT+'
';
valid = false;
}
if (!this.p1.value.match(/[a-z]/))
{
msg += MSG_PWLOWERCASE+'
';
valid = false;
}
if (!this.p1.value.match(/[A-Z]/))
{
msg += MSG_PWUPPERCASE+'
';
valid = false;
}
if (this.p1.value.match(/[^A-Za-z0-9]/))
{
msg += MSG_PWSPECIAL+'
';
valid = false;
}
msg = MSG_PWATTRIBUTE+'
'+msg;
}
if (valid)
{
this.c1c.innerHTML = this.imgOK + this.msgtrue;
this.c1.style.display = 'block';
}
else if (msg != '')
{
this.c1c.innerHTML = this.imgFAIL + msg;
this.c1.style.display = 'block';
}
else
{
if (this.c1c.innerHTML = '');
this.c1.style.display = 'none';
}
if (this.p2)
passwordMeter.equals();
return valid;
},
equals: function ()
{
if (this.p1.value != '' && this.p1.value == this.p2.value)
{
this.c2.innerHTML = this.imgOK;
return true;
}
else
{
this.c2.innerHTML = (this.p2.value != '') ? this.imgFAIL : '';
return false;
}
},
blur: function()
{
if (this.c1c.innerHTML = this.imgOK + this.msgtrue)
{
this.c1.style.display = 'none';
}
else
{
this.c1c.innerHTML = this.imgFAIL + msg;
this.c1.style.display = 'block';
}
}
};