我在 razor 视图引擎上有一个 ajax 表单。对于验证,我使用数据注释类。用户提交表单时验证工作正常,验证消息工作正常。问题是,验证不适用于 keyup 或 blur 事件。
如何在不提交 ajaxform(ajax.beginform) 的情况下激活验证
这是我的视图代码:
@using (Ajax.BeginForm(new AjaxOptions { InsertionMode = InsertionMode.Replace,
UpdateTargetId = "employeeDetail", HttpMethod = "Post", OnComplete = "Complete",
Confirm = "Confirm?" }))
{
@Html.TextBoxFor(model => model.Email)
@Html.ValidationMessageFor(model=>model.Email)
<span style="float:right"><input type="submit" class="tableGenelButton" id="submitButton" value="Kaydet" /></span>
}
模型:
[RequiredWithMessage]
[Display(Name = "E-Mail")]
public string Email { get; set; }