【发布时间】:2023-03-27 12:50:01
【问题描述】:
所以我有这两个输入字段 Fromdate 和 ToDate,
在 MVC 中,我想创建一个 CustomAttribute 以确保 Fromdate 在 ToDate 之前。
这可能吗?如果是这样怎么办?或者有什么替代方法?
谢谢
【问题讨论】:
-
这对您有帮助吗? codeproject.com/Articles/301022/…
-
它是否适用于多个领域?
-
正如文章开头所说:
There are lots of validation attributes available in MVC 3 but sometimes we may require specific type of validation which is dependent on some other properties as well。有问题的例子是I come across a situation where I need validation on a set of checkboxes. Validation I need was simple that at least one checkbox from the set must be checked,所以他申请的领域不止一个,是的。他正在检查是否至少选中了 3 个复选框中的一个。
标签: c# asp.net-mvc custom-attributes