如何使用 Html Validate 或 Html ValidateFor 显示错误警报
<script type="text/javascript">
$(document).ready(function () {
$("#RegisterForm").bind('invalid-form.validate',
function (event, validator) {
alert(validator.errorMap.FName);
console.log(validator.errorMap);
});
});
</script>
@using(Html.BeginForm()){
<span>First Name: </span>@Html.TextBoxFor(model => model.FName)
@{Html.ValidateFor(model => model.FName);}
}