The DataAnnotations validator not working in asp.net mvc 4 razor view, when using the special characters in the regular expression.
Model:
What browser are you using? I entered your example and tried in both IE8 and Chrome and it validated fine when I typed in the value Sam's
public class IndexViewModel
{
[Required(ErrorMessage="Required")]
[RegularExpression("^([a-zA-Z0-9 .&'-]+)$", ErrorMessage = "Invalid First Name")]
public string Name { get; set; }
}
When I inspect the DOM using IE Developer toolbar and Chrome Developer mode it does not show any special characters.