MVC客户端验证

引用JS

注意:删除Layout里面默认引用的JQUERY,否则可能引起JS冲突。

   <link href="~/Content/Site.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width" />
<script src="~/Scripts/jquery-1.8.2.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>

启用验证

        @Html.AntiForgeryToken()
@Html.ValidationSummary(true)

验证规则

        [DisplayName("会员姓名")]
[Required]
[MaxLength()]
public String MemberName { get; set; }

验证消息

@Html.ValidationMessageFor(m => m.UserName)
上一篇:Window检测网络连接情况


下一篇:Linux下yum升级安装PHP 5.5