I am using MVC.net 4 to build a web application. I need to regular expression for password to satisfy following conditions:
- Must be between 6-32 characters long.
- Must contain at least one lower case letter.
- Must contain at least one upper case letter.
- Must contain at least one numeric or special character.
Be careful about 4th point, I just need to expression of or condition between numeric and special character(not with and case for number and special character).
i am using following code that is working fine but need to use or case between Numeric and symbols.
[Required(ErrorMessage = "New Password is Required")]
[StringLength(32, MinimumLength = 6, ErrorMessage = "New Password should not be lessthan 6 character.")]
[RegularExpression(@"(?=.*[a-zA-Z0-9])(?=.*[~!@#$%^&*])[a-zA-Z0-9~!@#$%^&*]{8,15}", ErrorMessage = "Password should contain atleast one upper and lower character and on digit or special character.")]
public string NewPassword { get; set; }
i.e. I just need to password Expression as if set amanDeep1 then no need to check for symbol or if set as @amanDeep then no need to check for numeric values.