
var m_strUpperCase="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var m_strLowerCase="abcdefghijklmnopqrstuvwxyz";var m_strNumber="0123456789";var m_strCharacters="!@#$%^&*?_~"
function checkPassword(strPassword)
{var nScore=0;if(strPassword.length<5)
{nScore+=5;}
else if(strPassword.length>4&&strPassword.length<8)
{nScore+=10;}
else if(strPassword.length>7)
{nScore+=25;}
var nUpperCount=countContain(strPassword,m_strUpperCase);var nLowerCount=countContain(strPassword,m_strLowerCase);var nLowerUpperCount=nUpperCount+nLowerCount;if(nUpperCount==0&&nLowerCount!=0)
{nScore+=10;}
else if(nUpperCount!=0&&nLowerCount!=0)
{nScore+=20;}
var nNumberCount=countContain(strPassword,m_strNumber);if(nNumberCount==1)
{nScore+=10;}
if(nNumberCount>=3)
{nScore+=20;}
var nCharacterCount=countContain(strPassword,m_strCharacters);if(nCharacterCount==1)
{nScore+=10;}
if(nCharacterCount>1)
{nScore+=25;}
if(nNumberCount!=0&&nLowerUpperCount!=0)
{nScore+=2;}
if(nNumberCount!=0&&nLowerUpperCount!=0&&nCharacterCount!=0)
{nScore+=3;}
if(nNumberCount!=0&&nUpperCount!=0&&nLowerCount!=0&&nCharacterCount!=0)
{nScore+=5;}
return nScore;}
function runPassword(strPassword,strFieldID)
{var nScore=checkPassword(strPassword);var ctlBar=document.getElementById(strFieldID+"_bar");var ctlText=document.getElementById(strFieldID+"_text");if(!ctlBar||!ctlText)
return;ctlBar.style.width=nScore+"%";if(nScore>=90)
{var strText="Muy segura";var strColor="#0ca908";}
else if(nScore>=80)
{var strText="Segura";vstrColor="#7ff67c";}
else if(nScore>=70)
{var strText="Muy fuerte";var strColor="#1740ef";}
else if(nScore>=60)
{var strText="Fuerte";var strColor="#5a74e3";}
else if(nScore>=50)
{var strText="Media";var strColor="#e3cb00";}
else if(nScore>=25)
{var strText="Débil";var strColor="#e7d61a";}
else
{var strText="Muy débil";var strColor="#e71a1a";}
ctlBar.style.backgroundColor=strColor;ctlText.innerHTML="<span style='color: "+strColor+";'>"+strText+" - "+nScore+"</span>";}
function countContain(strPassword,strCheck)
{var nCount=0;for(i=0;i<strPassword.length;i++)
{if(strCheck.indexOf(strPassword.charAt(i))>-1)
{nCount++;}}
return nCount;}