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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -