RegularExpession Validator

Discussion in 'ASP .Net Web Controls' started by fdisk, Jun 10, 2004.

  1. fdisk

    fdisk Guest

    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
     
    fdisk, Jun 10, 2004
    #1
    1. Advertising

  2. fdisk

    stuart Guest

    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

    "fdisk" wrote:

    > 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
    >
     
    stuart, Jun 10, 2004
    #2
    1. Advertising

  3. Try this?

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

    Modified from this:

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

    Ken


    "fdisk" <> wrote in message
    news:...
    > 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
     
    Ken Cox [Microsoft MVP], Jun 11, 2004
    #3
  4. fdisk

    fdisk Guest

    "Ken Cox [Microsoft MVP]" <> wrote in message news:<>...
    > 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>
     
    fdisk, Jun 11, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Serdar Kalaycý

    Custom Validator

    Serdar Kalaycý, Jul 7, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    544
    Serdar Kalaycý
    Jul 8, 2003
  2. Antonio Maciel

    Validator controls and usercontrols

    Antonio Maciel, Jul 9, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    384
    Antonio Maciel
    Jul 9, 2003
  3. Mark Kamoski
    Replies:
    0
    Views:
    356
    Mark Kamoski
    Jul 16, 2003
  4. Herve MAILLARD
    Replies:
    2
    Views:
    524
    John Saunders
    Jul 23, 2003
  5. Replies:
    4
    Views:
    947
    Richter~9.6
    Feb 13, 2007
Loading...

Share This Page