All,
I am using ASP.NET MVC
and trying to do a Regular Expression to enforce Password requirements.
Register.cshtml:
@Html.ValidationMessageFor(model => model.Passwd, "", new {@class = "text-danger"})
Model Class:
[RegularExpression("/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).{8}/g",
ErrorMessage = "Password must meet requirements")]
public string Passwd { get; set; }
I copied out the RegEx and tested it standalone in RegexPal.com and it worked perfectly.
However, when using it in my ASP.NET MVC app, I get the error message every time (even using Passwords that I know meet the requirements.
Am I doing something wrong? Does the DataAttributes RegularExpression Attribute behave differently than standard RegEx?