I'm decorated a ViewModel in my ASP.NET MVC 2 site with System.ComponentModel.DataAnnotations
validation attributes. For one of my fields, named Price, I want to validate that the value is not below some extent, in this case 0.
I know that RangeAttribute
exists for validation with a lower and an upper extent, but does something like a MinimumValueAttribute
exist for validation with only a lower extent ?
If not, I guess I'll just roll my own.
在你自己滚动之前 - 尝试[Range(0.05, Double.MaxValue)]
不确定RegularExpression
是否是“最佳”解决方案,但您可以试一试
"^\$?\d+(\.(\d{2}))?$"
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.