regular expressions

Discussion in 'Javascript' started by Psybar Phreak, Sep 27, 2003.

  1. hi all, was hoping someone could provide a regex for the following
    situation - im pulling my hair out

    thanks

    PP


    --------

    Q) password needs to contain at least one number and have a minimum length
    of 6
     
    Psybar Phreak, Sep 27, 2003
    #1
    1. Advertising

  2. Psybar Phreak wrote:

    > hi all, was hoping someone could provide a regex for the following
    > situation - im pulling my hair out
    >
    > Q) password needs to contain at least one number and have a minimum length
    > of 6
    >


    I guess what you want is at least one digit and a minimum length
    if (document.formName.passwordName.value.length >= 6
    && /\d/.test(document.formName.passwordName.value))

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Sep 27, 2003
    #2
    1. Advertising

  3. Psybar Phreak

    Evertjan. Guest

    Psybar Phreak wrote on 27 sep 2003 in comp.lang.javascript:
    > hi all, was hoping someone could provide a regex for the following
    > situation - im pulling my hair out
    >
    > Q) password needs to contain at least one number and have a minimum
    > length of 6


    [If this is a school test, you take the credit, but not earn it]

    function testing(x){
    return /\d/.test(x) && /\S{6,}/.test(x)
    }

    document.write(testing("asdasdd4")+"<br>")
    document.write(testing("asdasdZZ")+"<br>")
    document.write(testing("dd4")+"<br>")


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Sep 27, 2003
    #3
  4. its not a school test.

    im developing a php site and im in charge of validation

    thanks

    daina


    "Evertjan." <> wrote in message
    news:Xns9403AC041E935eejj99@194.109.133.29...
    > Psybar Phreak wrote on 27 sep 2003 in comp.lang.javascript:
    > > hi all, was hoping someone could provide a regex for the following
    > > situation - im pulling my hair out
    > >
    > > Q) password needs to contain at least one number and have a minimum
    > > length of 6

    >
    > [If this is a school test, you take the credit, but not earn it]
    >
    > function testing(x){
    > return /\d/.test(x) && /\S{6,}/.test(x)
    > }
    >
    > document.write(testing("asdasdd4")+"<br>")
    > document.write(testing("asdasdZZ")+"<br>")
    > document.write(testing("dd4")+"<br>")
    >
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
     
    Psybar Phreak, Sep 28, 2003
    #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. Jay Douglas

    Custom Regular Expressions in ASP.net

    Jay Douglas, Nov 2, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    608
    mikeb
    Nov 3, 2003
  2. mark

    Regular expressions

    mark, Jun 30, 2003, in forum: Perl
    Replies:
    4
    Views:
    1,723
  3. Dustin D.
    Replies:
    1
    Views:
    11,217
  4. Jay Douglas
    Replies:
    0
    Views:
    610
    Jay Douglas
    Aug 15, 2003
  5. Noman Shapiro
    Replies:
    0
    Views:
    235
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page