Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 63087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:34:39+00:00 2026-05-10T18:34:39+00:00

I have a validation control that has the following expression: (?=(.*\\d.*){2,})(?=(.*\\w.*){2,})(?=(.*\\W.*){1,}).{8,} That’s a password

  • 0

I have a validation control that has the following expression:

(?=(.*\\d.*){2,})(?=(.*\\w.*){2,})(?=(.*\\W.*){1,}).{8,} 

That’s a password with at least 2 digits, 2 alpha characters, 1 non-alphanumeric and 8 character minimum. Unfortunately this doesn’t seem to be cross-browser compliant.

This validation works perfectly in Firefox, but it does not in Internet Explorer.

A combination of each of your answers results in:

var format = '^(?=.{' + minLength + ',})' +      (minAlpha > 0 ? '(?=(.*[A-Za-z].*){' + minAlpha + ',})' : '') +      (minNum > 0 ? '(?=(.*[0-9].*){' + minNum + ',})' : '') +      (minNonAlpha > 0 ? '(?=(.*\\W.*){' + minNonAlpha + ',})' : '') + '.*$';  EX: '^(?=.{x,})(?=(.*[A-Za-z].*){y,})(?=(.*[0-9].*){z,})(?=(.*\W.*){a,}).*$' 

The important piece is having the (?.{x,}) for the length first.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:34:40+00:00Added an answer on May 10, 2026 at 6:34 pm

    (?=(.*\W.*){0,}) is not 0 non-alphanumeric characters. It is at least 0 non-alphanumeric characters. If you wanted the password to not contain any non-alphanumeric characters you could do either (?!.*\W) or (?=\w*$).

    A simpler solution would be to skip the \W look-ahead, and use \w{8,} instead of .{8,}.

    Also, \w includes \d. If you wanted just the alpha you could do either [^\W\d] or [A-Za-z].

    /^(?=(?:.*?\d){2})(?=(?:.*?[A-Za-z]){2})\w{8,}$/ 

    This would validate the password to contain at least two digits, two alphas, be at least 8 characters long, and contain only alpha-numeric characters (including underscore).

    • \w = [A-Za-z0-9_]
    • \d = [0-9]
    • \s = [ \t\n\r\f\v]

    Edit: To use this in all browsers you probably need to do something like this:

    var re = new RegExp('^(?=(?:.*?\\d){2})(?=(?:.*?[A-Za-z]){2})\\w{8,}$'); if (re.test(password)) { /* ok */ } 

    Edit2: The recent update in the question almost invalidates my whole answer. ^^;;

    You should still be able to use the JavaScript code in the end, if you replace the pattern with what you had originally.

    Edit3: OK. Now I see what you mean.

    /^(?=.*[a-z].*[a-z])(?=.*[0-9].*[0-9]).{3,}/.test('password123') // matches /^(?=.*[a-z].*[a-z])(?=.*[0-9].*[0-9]).{4,}/.test('password123') // does not match /^(?=.*[a-z].*[a-z]).{4,}/.test('password123')                   // matches 

    It seems (?= ) isn’t really zero-width in Internet Explorer.

    http://development.thatoneplace.net/2008/05/bug-discovered-in-internet-explorer-7.html

    Edit4: More reading: http://blog.stevenlevithan.com/archives/regex-lookahead-bug

    I think this can solve your problem:

    /^(?=.{8,}$)(?=(?:.*?\d){2})(?=(?:.*?[A-Za-z]){2})(?=(?:.*?\W){1})/ new RegExp('^(?=.{8,}$)(?=(?:.*?\\d){2})(?=(?:.*?[A-Za-z]){2})(?=(?:.*?\\W){1})') 

    The (?=.{8,}$) needs to come first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 77k
  • Answers 77k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer A repository is only responsible for data retrieval/storage. A factory… May 11, 2026 at 3:28 pm
  • added an answer Just use {Binding} or {Binding Converter={...}} i.e. without a Path. May 11, 2026 at 3:28 pm
  • added an answer If you're looking for a tutorial or a book, rather… May 11, 2026 at 3:28 pm

Related Questions

I have a validation control that has the following expression: (?=(.*\\d.*){2,})(?=(.*\\w.*){2,})(?=(.*\\W.*){1,}).{8,} That's a password
Hopefully an easy one, I have created a Custom Repeater control that extends System.Web.UI.WebControls.Repeater.
I have a user control which contains a textbox. I have a class called
I've got a little c# windows service that periodically pulls xml from a web
I have a simple textbox with a required field validation control attached to end

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.