Skip to main content
April 24, 2007
Question

regular expression validation

  • April 24, 2007
  • 1 reply
  • 290 views
i have a form password to be server validated
the password needs to be at least 8 characters with at least 1 being numeric.

this expression example that i found is supposed to be 6-8 characters with at least 1 letter

/^(?![0-9]{6,8})[0-9a-zA-Z]{6,8}$/

can anyone help change this expression to match my requirements?

i can see the {6,8} being {8,9} but not sure of the other changes?

thanks for your help
jim balthrop
This topic has been closed for replies.

1 reply

Inspiring
April 24, 2007
Try:
^(?=.*[A-Za-z])(?=.*[\d])(?!.*[A-Za-z0-9])(?!.*s).{8,}$

That should require at least 8 characters with one digit.
It might be easier just to do separate tests, though. Up to you, really.

Pseudocode:
If Len(password) >= 8
RegExp = "[\D]"
stripped password = RegExp.Replace(password,"")
If Len(stripped password) > 0
OK!
Else
You forgot to include a number!
End
Else
That's not long enough
End


"jim balthrop" <webforumsuser@macromedia.com> wrote in message
news:f0lpte$blc$1@forums.macromedia.com...
>i have a form password to be server validated
> the password needs to be at least 8 characters with at least 1 being
> numeric.
>
> this expression example that i found is supposed to be 6-8 characters with
> at
> least 1 letter
>
> /^(?![0-9]{6,8})[0-9a-zA-Z]{6,8}$/
>
> can anyone help change this expression to match my requirements?
>
> i can see the {6,8} being {8,9} but not sure of the other changes?
>
> thanks for your help
> jim balthrop
>
>


April 25, 2007
couldn't get that to work but i did find the answer on line

i found this expression for at least 1 numeral and at least 1 letter
/^\w*(?=\w*\d)(?=\w*[a-z])\w*$/

i ended up applying a seperate validation for the minimum characters of 8 and applied both the entry length and the regular expression validation to the password textbox

thanks for your help; it pointed me in the right direction