我有一个Asp.Net MVC项目 . 我正在尝试为editorFor进行电子邮件验证 .
根据我研究的方式[在这个答案:How to apply input which has a type email to to HTML Helper in Asp.net MVC3 Razor以及更多......]来做这件事是这样的:
@Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control", @dir="ltr", @type = "email"} })
唯一的问题是,这确保我有这种模式: name@gmail 但它不能确保 @ 之后的某个地址的电子邮件地址中有 . - [ name@gmail.com ] .
关于我能做什么的任何想法?谢谢
1 回答
在你的模型中使用这个:
添加
using System.ComponentModel.DataAnnotations;
这将正确验证我使用此电子邮件地址 .