为什么页面加载后就直接显示了验证信息,都还没开始输入邮箱Html代码如下:@model Person
@{
Layout = null;
}<script src="~/Scripts/jquery-1.10.2.min.js"></script><script src="~/Scripts/jquery.validate.min.js"></script><script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script><form >@Html.TextBoxFor(m => m.Email)
@Html.ValidationMessageFor(m => m.Email)<button id="btn">提交</button></form> 后台代码如下:namespace MVCEasyUI.Controllers
{public class HomeController : Controller
{public ActionResult FormValid(Person person)
{return View(person);
}
}
}public class Person
{
[Required(ErrorMessage = "{0}必填")]
[EmailAddress(ErrorMessage = "邮箱格式不正确")]
[Display(Name = "邮件")]public string Email { get; set; }
}
- 1 回答
- 0 关注
- 358 浏览
添加回答
举报
0/150
提交
取消