Search code examples
asp.net-mvcvalidationasp.net-mvc-4data-annotationsclient-side-validation

ASP.Net Mvc Fixed-Length String Data Annotation


How can I set the string validation for a fixed-length string using data annotation ?

I want to have a property on my model with the exact 10 string-length.

I'm counting the seconds for help.


Solution

  • 1) [StringLength(10, MinimumLength = 10)]

    2) [RegularExpression(@"(.{10})")]