Regex validator for Password complexity

Can Regex validator be used to check for password complexity?

I don't see why not, I googled and found one that checks for proper IP address formatting, and it works great with the Radzen Regex validator. Try something from


1 Like

It's funny but in my research I came up with that same site and used that same expression but omitted the ".{6,}$" length expression or that is what I thought. Of course that didn't work.

Since you pointed to that same site, I tried it again but without no modification and it worked. With that understanding, I was able to break up the password complexity validation into individual checks so as to inform the user of what's missing in their password. It works like a charm. I included the markup.

Thank you Stephen.


<RadzenPassword style="display: block" Name="Password" @bind-Value="model.Password" />
<RadzenRequiredValidator Component="Password" Text="Please enter a password!" <RadzenLengthValidator Component="Password" Min="6" Text="You are required to enter 6 or more characters!" />
<RadzenRegexValidator Component="Password" Text="Please use at least one lower case letter!" Pattern="^(?=.*[a-z]).{1,}$" />
<RadzenRegexValidator Component="Password" Text="Please use at least one upper case letter!" Pattern="^(?=.*[A-Z]).{1,}$" />
<RadzenRegexValidator Component="Password" Text="Please use at least one non-alphanumeric character!" Pattern="^(?=.*[!\#$%^&*()]).{1,}$" />
<RadzenRegexValidator Component="Password" Text="Please use at least one number!" Pattern="^(?=.*\d).{1,}$" />

Bravo! I'm bookmarking your markup, will be useful...


How do we include the @ character in the Pattern?

Hi @Jonski,

Try pugging it inside the [] block of the RegEx.


Hi @korchev,

Tried doing that but .Net IDE is marking it as an error.


You need to escape @ as it is a special symbol.

I see. Thanks @korchev . Still getting used to this. :slight_smile:

Still getting the same error

Ended up doing this and escaped \ instead