这里的问题很简单(我想).
我的表单底部有一个复选框,用户必须同意条款和条件.如果用户没有选中该框,我想在我的验证摘要中显示一条错误消息以及其他表单错误.
我将此添加到我的视图模型中:
[Required]
[Range(1, 1, ErrorMessage = "You must agree to the Terms and Conditions")]
public bool AgreeTerms { get; set; }
Run Code Online (Sandbox Code Playgroud)
但那没用.
有一种简单的方法可以使用数据注释强制值为true吗?