user3824109
user3824109

Reputation: 81

Why isn't my password complexity regex accepting my value?

I have given Regular Expression for Password Property as

[RegularExpression(@"^((?=.*\\d)(?=.*[a-z])(?=.*[@#$%.]).{8,16})*$", ErrorMessage = "Password must contain atleast one digit and one speacial character")]
public string Password{get; set;}

I have given password as bobby@15. I am not able to register. Is there any problem with Regular expression

Upvotes: 1

Views: 136

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174696

Don't need to escape \d.

@"^((?=.*\d)(?=.*[a-z])(?=.*[@#$%.]).{8,16})*$"

Upvotes: 1

Related Questions