I have a Regular Expression Validation for a Single Capital Letter, but it does not work.
When I put in a valid letter, I get the error message;
[DisplayName("Contract Letter")]
[RegularExpression("[A-Z]", ErrorMessage = "Must be a letter")]
[Required(ErrorMessage = "A Letter is required")]
public string ContractNo_Letter { get; set; }
I am only allowing the input of 1 letter.
A couple of things to consider here:
8979*(&#$HJwill evaluate to true. To match exactly one letter, you can wrap your regex with the special characters:^(start of line), and$(end of string).[A-Za-z].So, to match a single letter without case sensitivity, use
^[A-Za-z]$.