[Display(Name = "Mobile")]
public string Mobile { get; set; }
在上面的代码中,我希望包含类似......
的内容[Required(ErrorMessage="If you don't enter your email we cant send a text confirmation")]
但是,我不想让这个领域成为必需的。只要用户没有输入任何内容,他们就会收到一条消息说明这一点。这可能吗?
谢谢
答案 0 :(得分:0)
您必须编写自己的UI控件以支持此类提示。它与用于验证的常见数据注释无关,因此您无法使用Required
。