I wrote the following little validation routine to validate a password:
Subject: Using javascript to validate password
Betsy,
This variation will work (you just need to tweak a bit):
Button code:
<input type=“Button” value=“submit” onClick=“if ( doSubmit(document.forms[0], true ) ) document.forms[0].submit();”
JSHeader:
Subject: RE: Using javascript to validate password
Thanks alot… I got it to work. Really appreciate your help…
Subject: RE: Using javascript to validate password
Not a problem. I had only worked with regular expressions once before and it was good to think about them again. My next goal is to get the code I posted into one line that works, though breaking it out may make it easier to customize the return message.
Subject: RE: Using javascript to validate password
Well, I have another requirement…
the password needs to have at least one numeric or one special character (like ~!@#$%^&*())
I tried to add:
(?=\W*[~!@#$%^&*((])
but it didn’t work…
Any suggestions on how to modify my expression to allow a special character as opposed to a numeric character…
thanks in advance…
Subject: RE: Using javascript to validate password
Almost all “special characters” are special in regular expressions as well – you need to escape them, so ^ becomes ^, etc.
Subject: RE: Using javascript to validate password
actually, this code I just sent Betsy does work (except for checking the maximum 15 characters):
function doValidation(f)
{
alert (“starting validation”);
var pw = f.Password.value
var reg =/^.(?=.{8,15})(?=.[a-z])(?=.[A-Z])((?=.\d)|(?=.[~!@#$%^&()])).*$/;
if (!reg.test(pw))
{
alert(pw + " is an invalid password!");
f.Password.focus();
return false;
}
}
Subject: RE: Using javascript to validate password
Thank you thank thank you!!! From the bottom of my heart… I did try…
I was sort of close…
I worked on it all day…
Thanks so much… Wonderfull…