OK, I'm trying to learn. I really am.

That said, I just can't get this to work.

This is JavaScript on a web page, trying to validate the business rules 
for a password. Simple: has to contain at least one alpha character and 
at least one digit. Minimum 7 chars total.

So the evaluation JS and RegEx:
---------------------------------------------------------------
if (document.form_general.passwordverify.value == "") {
  msg = msg + "\n - Verify the Password you Chose";
} else if (document.form_general.txtpassword2.value != 
document.form_general.passwordverify.value) {
  msg = msg + "\n - the Passwords you entered do not match";
} else if (document.form_general.passwordverify.value.length < 7)  {
  msg = msg + "\n - The password is the wrong length";
} else if (illegalChars.test(document.form_general.passwordverify.value)) {
  msg = msg + "\n - The password contains illegal characters";
} else if (!document.form_general.passwordverify.value.search(/[0-9]+/)) {
  msg = msg + "\n - The password must contain a DIGIT";
} else if 
(!document.form_general.passwordverify.value.search(/[a-zA-Z]+/)) {
  msg = msg + "\n - The password must contain an ALPHA";
}
---------------------------------------------------------------

My problem is with the last 2 "else if" lines.

  -- If I do all digits, it says I need a digit!
  -- If I do all alphas, it says I need an alpha.

So, I figured the dag-nabbit thing is just backward, so I eliminate the 
"!" in the logic (even if it seems illogical).

  -- If I do all digits, it says I need a alpha (yay).
  -- If I do all alphas, it says I need an digit (yay).
  -- if I add a digit to the alpha, it says I need a digit. (crap)

It seems only to be evaluating the first character, in spite of the "+?" 
in there. I tried adding numbers in {} but that brought "unexpected" 
results: no rules were enforced at all.

Anyone willing to help me understand what I am doing wrong???

Ken

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to