0
votes

The password validation requirements for my input field are as follows: "Password should contain at least one uppercase, one lowercase letter, one number OR special character".

This is the regex for 1 uppercase, 1 lowercase, 1 number AND one special character

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]
2
Are you asking us to explain your own password requirements, or the regex?Ken White

2 Answers

2
votes

I think you need a regex like this:

^(?=.*[a-z])(?=.*[A-Z])(?=.*[\d$@$!%*?&]).*$

In [\d$@$!%*?&] you have at least one number OR one special character.

0
votes

I think this one help you

((?=.*\d)(?=.*[A-Z])(?=.*\W).{8,8})

Password must be 8 characters including 1 uppercase letter, 1 special character, alphanumeric characters