0

我有一个View从 加载的 partial ,Action所以父视图包含:

@Html.Action("TourSearch")

TourSearch 视图使用如下编辑器:

@Html.EditorFor(model => model.ImpersonatedAgentModel, "ImpersonatedAgentView")

在哪里ImpersonatedAgentModel是这样的:

[Serializable]
  public class ImpersonatedAgentModel
  {
    [Required(ErrorMessage = "Please provide a User ref")]
    public string AgentImpersonatedUserName { get; set; }
    [Required(ErrorMessage="Please provide a ABTA/AgencyCode")]
    public string AgentImpersonatedBranchCode { get; set; }
    [Required(ErrorMessage = "Please provide a User ref")]
    public int? AgentImpersonatedBranchID { get; set; }
  }

我的编辑器非常直截了当:

@model Travel2.WebUI.Models.ImpersonatedAgentModel

<ul id="agencyDetails">
    <li>
        <label for="AgentImpersonatedBranchCode">ABTA/Agency Code: *</label>
        @Html.TextBoxFor(model => model.AgentImpersonatedBranchCode, new {ID="txtBranchCode" })
            @Html.ValidationMessageFor(model => model.AgentImpersonatedBranchCode, "*")
        <input id="txtBranchId", type="hidden" value="@Model.AgentImpersonatedBranchID" />
        <input id="txtUserName", type="hidden" value="@Model.AgentImpersonatedUserName" />
        <input id="hidCurrentController" type="hidden" value='@ViewContext.Controller.ValueProvider.GetValue("controller").RawValue' />
    </li>
    <li>
        <label for="AgentImpersonatedUserName">User ref: *</label>
        <select id="ddlUser" disabled="disabled" ></select>
                <input type="hidden" id="txtUserID" />
                @Html.HiddenFor(model => model.AgentImpersonatedUserName, new {ID="AgentImpersonatedUserName" })
                @Html.HiddenFor(model => model.AgentImpersonatedBranchID, new {ID="AgentImpersonatedBranchID"})
                            @Html.ValidationMessageFor(model => model.AgentImpersonatedUserName, "*")

    </li>

</ul>

现在在 Chrome 中,一切正常。但是当我在IE中填写表单而不是在编辑器中填写数据时,它会错误地通过验证

如果我检查标记,使用 IE 对 Firebug 的糟糕借口,我可以看到验证属性,

<input name="ImpersonatedAgentModel.AgentImpersonatedBranchCode" id="txtBranchCode" type="text" data-val="true" data-val-required="Please provide a ABTA/AgencyCode" jQuery172048066185567747205="94"/>

那么为什么 IE 会忽略它们!愚蠢的 IE

4

1 回答 1

1

Found the answer here:

http://www.tigraine.at/2011/08/26/jquery-validate-and-microsofts-unobtrusive-validation-dont-play-well-together/

We were referencing Jquery validation too and this seems to be causing this error

于 2013-01-24T14:46:55.270 回答