regular expressions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Psybar Phreak

    #1

    regular expressions

    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



  • Martin Honnen

    #2
    Re: regular expressions



    Psybar Phreak wrote:
    [color=blue]
    > 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
    >[/color]

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

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    • Evertjan.

      #3
      Re: regular expressions

      Psybar Phreak wrote on 27 sep 2003 in comp.lang.javas cript:[color=blue]
      > 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[/color]

      [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("asdasd d4")+"<br>")
      document.write( testing("asdasd ZZ")+"<br>")
      document.write( testing("dd4")+ "<br>")


      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress)

      Comment

      • Psybar Phreak

        #4
        Re: regular expressions

        its not a school test.

        im developing a php site and im in charge of validation

        thanks

        daina


        "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message
        news:Xns9403AC0 41E935eejj99@19 4.109.133.29...[color=blue]
        > Psybar Phreak wrote on 27 sep 2003 in comp.lang.javas cript:[color=green]
        > > 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[/color]
        >
        > [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("asdasd d4")+"<br>")
        > document.write( testing("asdasd ZZ")+"<br>")
        > document.write( testing("dd4")+ "<br>")
        >
        >
        > --
        > Evertjan.
        > The Netherlands.
        > (Please change the x'es to dots in my emailaddress)[/color]


        Comment

        Working...