简体   繁体   中英

How would I validate string length using DataAnnotations in asp.net mvc?

I am using DataAnnotations in an ASP.NET MVC 1 application to check for Required fields and numerical ranges using the Required and Range attributes.

I am looking for the best way to validate the length of strings in a few input text boxes. I see that there is a RegularExpression attribute that could do the job but I was wondering if there was a more specific attribute to do this?

Also if anyone can point me to a decent resource regarding using DataAnnotations I would be very grateful.

StringLength属性怎么样?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM