我在弹出窗口中放置了以下代码。基本上我想要实现的是在这种情况下验证所需的字段 HRN。不幸的是,没有显示验证。请让我知道如何解决此问题。谢谢
看法:
@model HHIMS_Web_App.Models.CModel
<div>
<fieldset id="AddNew">
@using (Html.BeginForm("CreateList", "Details", FormMethod.Post, new { id = "frmAsset" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<div>
<div class="addConsumerInfo">
@Html.LabelFor(model => model.HRN)
@Html.EditorFor(model => model.HRN)
@Html.ValidationMessageFor(model => model.HRN)
</div>
<div class="consumerAddSmallBox">
@Html.LabelFor(model => model.DOB)
@Html.EditorFor(model => model.DOB)
</div>
</div>
}
</fieldset>
</div>
<input type="button" id="btnSave" style="height:50px; width:85px; font-size:14px; background-color:#3399FF;white-space: normal" class="k-button" title="Save" value="Save"/>
<script type="text/javascript">
$('#btnSave').click(function () {
var dropdownlist = $("#Gender").data("kendoDropDownList").select();
$.ajax({
type: 'POST',
url: "@Url.Action("CreateList","Details")",
data: {
HRN: $("#HRN").val(),
DOB: $("#DOB").val()
},
success: function () {
window.close()
}
});
});
</script>
模型:
[Required(ErrorMessage = "Required")]
[DisplayName("HRN")]
public string HRN { get; set;