Regular Expression error message

eddy28 1 Reputation point
2021-06-09T08:53:07.437+00:00

Hello,

I wanted to include a regular expression to detail the parameters for a password, but I wanted to include an error message in order to see which parameters are fulfilled or not. Ive tried multiple regular expressions but that is illegal. How would I be able to implement this without complicating it further and creating a new class etc.

This is my code for the regular expression: [RegularExpression(@"^(?=.*[a-z])|(?=.*[A-Z])|(?=.*\d)|(?=.*[^a-zA-Z\d])$", ErrorMessage = "Password should have atleast one lowercase | atleast one uppercase, should have atleast one number, should have atleast one special character")]

while I want it to look similar to this:

103718-password.png

Where it updates whichever parameters are missing or fulfilled, how would I be able to do this the most effective way?
Thanks!

Developer technologies ASP.NET ASP.NET Core
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.