I’d rather not disable validation on my form. I feel like I’m not taking advantage of MVC’s benefits if I do that. Is there a way to regex the contents of a property submitted in a form before mvc gets its hands on it? I simply want to allow only alphanumerical values and some symbols but still leave protection on. Do I have to disable with [ValidateInput(false)]??
Share
You can create custom validation attributes and apply them to your entire model class, or individual properties.
http://odetocode.com/blogs/scott/archive/2011/02/21/custom-data-annotation-validator-part-i-server-code.aspx