复杂模型验证
有没有办法使用复杂的规则来实现模型验证,例如“如果选择了一个单选按钮,则需要从另一个单选按钮组中选择一个单选按钮。如果选择了带有附加文本框的单选按钮,则也需要填充它。”? 如果这种方式能与 DataAnnotations 属性相关就完美了。我只知道我们可以使用一些额外的框架来实现这一目标。但是,你知道,如果我们有一些本地解决方案,那就更漂亮了。 提前谢谢你们了!
Is there ways to implement model validation with complex rules like "if one radio button was selected it's necessary to select one radio from another radio buttons group. If radio button with additional textbox was selected so it's necessary to fill it too."?
It'll be perfect if this way will relate to DataAnnotations
attributes. I only know that we can use some additional framework to reach this. But, you know, it'll be more beautiful if we have some native solution.
Thanks you guys in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为 MVC-2 有原生解决方案,但我相信 MVC-3 支持使用 RemoteAttribute 进行远程验证的概念。我认为更多信息可以找到:
MVC 3 发行说明概述
RemoteAttribute
I don't think MVC-2 has a native solution but I believe MVC-3 supports the concept of remote validation using a RemoteAttribute. I think more information can be found:
MVC 3 Release notes overview
RemoteAttribute