c# - Using DataAnnotations with Regular Expressions to not Match -


is possible dataannotations , regular expressions filter entry in text box ? i.e. trigger invalid response when word "apt" in string ?

yes can using negative look-arounds, this:

public class mymodel {     [regularexpression(@"^((?!apt).)*$", errormessage = "you can not have that")]     public string myvalue { get; set; } } 

here reference question these types of regular expressions.

regular expression match string not containing word?


Comments