0

I have a textbox which letting user to enter their password.
My password format is

  1. Starting at least 1 non-alphanumeric
  2. Continue with alphanumeric
  3. Length: 7 and above.

What should i put in the validate expression?

<asp:RegularExpressionValidator ID="RegExpPass" runat="server" ErrorMessage="Password Length at Least 7 With Special Character" ControlToValidate="txtPass" ValidationExpression="^[a-zA-Z0-9'@&#.\s]{7}$" ForeColor="Red" />
2
Contributors
4
Replies
9
Views
3 Years
Discussion Span
Last Post by gahhon
0

^.*(?=.{7,})(?=.*[\d])(?=.*[\W]).*$
I Tested for this, it's so useful
1. Contain at least non-alphanumeric
2. Contrain at least numeric

But it doesn't allowed with alpha with non-alphanumeric, whereas non-alphanumeric with numeric is allowed.

how can i modify this code to become at least 1 non-alphanumeric with alphanumeric (no matter is full alpha or numeric is still allowing)

0

^.*(?=.{7,})(?=.[a-zA-Z])(?=.*[\d])(?=.*[\W]).*$

Thanks folk, i found the solution by keep searching the single thing and try it myself on TEST

  1. at least non-alphanumeric
  2. at least alphanumeric

RESULT

  • 1234567 Not Match
  • abcdefg Not Match
  • abc1234 Not Match
  • !abcdef Not Match
  • !123456 Not Match
  • !abc123 Match
0

By no means am I a regex expert but here is an example that meets the requirements.

 ^[._%+-/$][a-zA-Z0-9]{5}[a-zA-Z0-9]+$

There are other ways to write the regex but this requires the first to be a special character, then 5 more of alpha and numeric then one or more alpha and numeric characters.

0

I will suggest my expression at first,
because it is checking the whole string whether is containing those requirements, no matter where it is.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.