Password Regular Expression mvc c#

MVC Password Regular Expression C#

using System.ComponentModel.DataAnnotations set password validation expression
  • At least 5 characters long
  • Contain at least 1 letter
  • Contain at least 1 number

[RegularExpression(@"(?=.*\d)(?=.*[A-Za-z]).{5,}", ErrorMessage = "Your password must be at least 5 characters long and contain at least 1 letter and 1 number")]
[RegularExpression(@"(?=.*\d)(?=.*[A-Za-z]).{5,}", ErrorMessage = "Your password must be at least 5 characters long and contain at least 1 letter and 1 number")]
[DataType(DataType.Password)]
public string Password { get; set; }
Password Regular Expression mvc c# Password Regular Expression mvc c# Reviewed by Bhaumik Patel on 9:06 PM Rating: 5