RegularExpession Validator

F

fdisk

Oh great Regular Expression gurus - I summon thee...

I know this is probably about as trivial as it gets for someone with
regular expression experience, but I don't. I was wondering if
someone would be able to create a regular expression (for validating
user passwords) that matches the following:

All of the following must be true for a match:

6-12 length - Isn't it something like {6,12}
Must include 1 or more lowercase - [a-z]
Must include 1 or more uppercase - [A-Z]
Must include 1 or more numeric - [0-9]

That's it, from the little I know, those are the patterns that it
should use, but I have no idea how to create the full statement.

TIA!

JB
 
S

stuart

Hi there,

I ain't no guru and may be slapped down, but I don't think you can do all that in validation controls. I would simply use a label control and activate a custom validation function when then page is posted back, all of what you said is dead easy with strings.

cya
 
F

fdisk

Ken Cox said:
Try this?

"^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,12}$"

Modified from this:

http://regexlib.com/REDetails.aspx?regexp_id=598

Ken

Thanks for the response Ken, I did check out that regex before, even
tried the tester on the website - it doesn't appear to match
upper-case. For instance "testtest" fails, but "testtest12" matches.
It's even funkier in the regularexpression validator control, where I
could never get it to pass...

Here is my aspx code - any ideas what I am doing wrong?

<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator id="RegularExpressionValidator1"
runat="server" ErrorMessage="RegularExpressionValidator" ControlToValidate="TextBox1"
ValidationExpression="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,12}$"></asp:RegularExpressionValidator>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top