Password Validation

Just trying not to recreate a wheel that someone may have already done. I am hoping someone has a javascript library, or code, that has password validation. (IE- Checking for length of 7 or more, at least one cap, and at least one number).

I am figuring their is a snippet of code out there somewhere, but spending alot of time trying to dig through javascript sites, which are trying to do all the encryption and the like.

So if you have that code, and willing to help me, I would appreciate it.

Subject: Password Validation

OK. Talking to another programmer, He told me I could try the mechanism of checking for the whole alphabet (a,b,c,d…) If this is true, move onto the Caps (A,B,C,D…) If this is true, check to see if there is at least a number showing up (0,1,2,3,4,5,6,7,8), and of course check the length for 7 characters. I am looking through my javascript book high and low for the command(s?), to compare a field, with these list to make sure at least one occurance is happening. I looked up instring, inlist, etc. Can someone tell me if there is such a command, and if so, what is that javascript command? Any help would be appreciated.

Subject: RE: Password Validation

The JavaScript command equivalent to Instr is:

lookInString.indexOf(lookForString)

… but that’s not what you want. Your length is easy enough to test:

if (value.length < 7) {

alert(‘Not long enough’);

}

The rest can be done with Regular Expressions. You can create a single funky regEx to do the whole thing in one pass, but this version works:

var re1 = /[A-Z]/; //all upper-case letters

var re2 = /\d/; //all digits

if (value.length < 7) {

alert(‘Not long enough’);

}

else if (!re1.test(value)) {

alert(‘No capital letters’);

}

else if (!re1.test(value)) {

alert(‘No numbers’);

}

Note that you’ll want to do something just a little more sophisticated than alert a half-English sentence fragment on failure, but I’m sure you knew that already.

Check this out for more:

http://www.evolt.org/article/Regular_Expressions_in_JavaScript/17/36435/

Subject: RE: Password Validation

Thank you Stan. I just kinda new that you might have been one to answer it. Thanks alot. I finally came across the regEx yesterday late, and was going to look through that today. I appreciate your help once again, and this little script will go into my bucket of tricks.