我的模型是:
[Required]
[DataType(DataType.EmailAddress)]
[Display(Name="Email Address")]
public string Email { get; set; }
当我使用时EditorFor(m=>m.Email),UI(JQuery 验证)会自动验证电子邮件地址。但我需要将form-control类插入 UI 控件。所以我改为EditorFor喜欢TextBoxFor:
@Html.TextBoxFor(m => m.Email , new { @class = "form-control" })
但是现在电子邮件验证不起作用。
如何将课程添加到EditorFor或添加电子邮件验证TextBoxFor(哪个或两者是最好的方法?)。我还有其他 6 处房产,一切都很好。除了这个。