-6

this regex is used to test the password that support at least one lower case and upper case alphabets and numbers. this regex is not support 6 to 20 characters support.

/(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}/

/*
 var result = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}/;
 return result.test(value);
*/  
vijay
  • 244
  • 4
  • 16

1 Answers1

1

Working Snippet

var password = prompt("Enter password", "1234567890Aa1234567890");

var regex = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,20}$/;

console.log("Password valid?: ", regex.test(password));

The regex had 2 things missing

  1. The range {6,20}
  2. Plus, the ^ and $, in the start and end of the regex. They signify, that the regex should apply end to end, and not a subset of the string.
Abhijit Kar ツ
  • 1,732
  • 1
  • 11
  • 24