Thursday, 8 August 2013

Regular Expression Match for Password

Regular Expression Match for Password

I'm building a form in ASP.Net using VB and I have a text box that I'd
like to validate against the following rules:
Must be 6 - 20 characters long
Can Contain Letters and Could Be ALL letters
Can Contain The Following Special Characters: !@#$%^&*+-=(){}:;,'./?
Cannot contain any whitespace.
Cannot be all numbers and does not REQUIRE a number
The case does not matter
Those requirements aren't set by me...That's just what I have to work with.
So, the following would match:
TestUserPass
Te$tU$e^p@%}
testuserpass
test{user}n@ame
The following would not match:
8392039
dhj#5|3j
Hopefully that gives an idea of what I'm looking for...
Here's what I have so far: \b[a-zA-Z0-9!@#\$%\^&*+=(){}:;,'./\?-]{6,20}\b
I believe that's working for everything EXCEPT the invalidating the
instance where the entry is all numbers. It's the all numbers portion that
I've been struggling with, though perhaps someone will find a flaw in what
I already have. Any help is greatly appreciated!

No comments:

Post a Comment