我似乎无法获得客户端验证工作具有以下局部视图。 这种观点在里面父视图divTSettings股利。 试过很多来自计算器和其他网站的事情,似乎没有任何工作。 有任何想法吗?
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
@using (Ajax.BeginForm("CreateT", "TAdmin", null,
new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "divTSettings"},
new { id = "CreateTForm" }))
{
<div>
<label>Name:</label>
<input type="text" name="tName" id="tName"/>
@Html.ValidationMessage("tName")
<input type="submit" value="Submit"/>
</div>
}
<script type="text/javascript">
$(function() {
$('#CreateTForm').validate({
rules: {
tName: {
required: true
}
},
messages: {
tName: {
required: 'Name required'
}
}
});
$("#CreateTForm").removeData("validator");
$("#CreateTForm").removeData("unobtrusiveValidation");
$.validator.unobtrusive.parse("#CreateTForm");
});
</script>