Hey guys!
So, in this registration form that I made! I have a real time password strength script.
Now the problem is that say if I type in 7 characters and a _ or - or a / it will put it as strong. But however, that's not what I want. I want it to do like this: monkey1/11 and then it it was strong.
Here's the script:
CODE
<script language="javascript" type="text/javascript">
var minpwlength = 4;
var fairpwlength = 7;
var STRENGTH_SHORT = 0; // less than minpwlength
var STRENGTH_WEAK = 1; // less than fairpwlength
var STRENGTH_FAIR = 2; // fairpwlength or over, no numbers
var STRENGTH_GOOD = 3; // fairpwlength or over with at least one number
var STRENGTH_STRONG = 4;
img0 = new Image();
img1 = new Image();
img2 = new Image();
img3 = new Image();
img4 = new Image();
img0.src = 'images/strenghtbar.png';
img1.src = 'images/strenght_weak.png';
img2.src = 'images/strenght_fair.png';
img3.src = 'images/strenght_good.png';
img4.src = 'images/strenght_strong.png';
var strengthlevel = 0;
var strengthimages = Array( img0.src,
img1.src,
img2.src,
img3.src,
img4.src );
var strengthstat = Array(' ','Weak','Fair','Medium','Strong');
function updatestrength( pw ) {
if( istoosmall( pw ) ) {
strengthlevel = STRENGTH_SHORT;
}
else if( !isfair( pw ) ) {
strengthlevel = STRENGTH_WEAK;
}
else if( hasnum( pw ) ) {
strengthlevel = STRENGTH_GOOD;
}
else if(( hassymb(pw)) || (hasnum(pw))){
strengthlevel = STRENGTH_STRONG;
}
else {
strengthlevel = STRENGTH_FAIR;
}
document.getElementById( 'strength' ).src = strengthimages[strengthlevel];
document.getElementById('strength_status').innerHTML = strengthstat[strengthlevel];
}
function isfair( pw ) {
if( pw.length < fairpwlength ) {
return false;
}
else {
return true;
}
}
function istoosmall( pw ) {
if( pw.length < minpwlength ) {
return true;
}
else {
return false;
}
}
function hasnum( pw ) {
var hasnum = false;
for( var counter = 0; counter < pw.length; counter ++ ) {
if( !isNaN( pw.charAt( counter ) ) ) {
hasnum = true;
}
}
return hasnum;
}
function hassymb(pw) {
var hassymb = false;
for( var count = 0; count < pw.length; count++) {
if( pw.charAt(count) == '_') {
hassymb = true;
}
else if( pw.charAt(count) == '-') {
hassymb = true;
}
else if( pw.charAt(count) == '/') {
hassymb = true;
}
}
return hassymb;
}
Thanks for the helps guys - really appreciate it!

-Paul