当我单击按钮客户端验证不起作用时,下面是我的视图和模型
看法:
<script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
@using (Html.BeginForm("Guestlogin", "Home", FormMethod.Post))
{
for (int i =0; i <1; i++)
{
@Html.DropDownListFor(per => per.[i].Gender, new[] {
new SelectListItem(){Text = "Male" , Value="Male"},
new SelectListItem(){Text ="Female" , Value = "Female"},
}, "Select Your Gender")@Html.ValidationMessageFor(o => o[i].Gender)
}
<button type="submit" name="Button"/>
}
模型:
[Required]
public string Gender { set;get;}