【问题标题】:How to validate model bound form using jquery on ajax post?如何在 ajax 帖子上使用 jquery 验证模型绑定表单?
【发布时间】:2019-11-14 01:04:53
【问题描述】:

我正在使用具有必需标签的模型绑定字段的 mvc 表单。

但是通过序列化表单使用 ajax post 提交它们。

现在验证消息不会出现。

【问题讨论】:

    标签: c# jquery asp.net-mvc validation


    【解决方案1】:

    使用

     @using (Ajax.BeginForm)
    

    代替

    @using (Html.BeginForm 
    

    还有 -

     @Html.ValidationMessageFor(model => model.EmailOrContactField, "", new { @class = "text-danger error-msg" })
    

    【讨论】:

      【解决方案2】:

      我认为您可能需要为视图页面中的每个模型项添加@html.validationmessagefor?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-01-26
        • 2011-06-01
        • 1970-01-01
        • 1970-01-01
        • 2019-04-27
        • 1970-01-01
        • 1970-01-01
        • 2013-02-18
        相关资源
        最近更新 更多