我在另一个视图中有部分视图。部分视图是“登录”部分。我正在使用 jquery 验证。请看附图。
这里的要求是,谁已经注册,他们将输入用户名/密码并进入下一页。(在登录部分视图中)和那些尚未注册的人,他们将输入电子邮件/密码/全名并进入下一页。(在主视图中)
在主视图中,必填字段很少。例如:电子邮件、密码等。现在的问题是,如果我在登录部分视图中输入用户名/密码,它不允许我继续。它给了我主视图中必填字段的错误。
这仅在 IE In FF 和 Crome 中发生,它可以按我的意愿工作。
知道在这种情况下该怎么办吗?
代码:登录部分:
<script src="<%: Url.Content("~/Scripts/jquery.validate.min.js") %>"    type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js") %>"     type="text/javascript"></script>
<% using (Html.BeginForm("LogOn", "Account", new { returnUrl =     Request.QueryString["returnUrl"] }))
 { %>
<div>
        <div class="editor-label">
            <%:Html.Label("Email") %>
        </div>
        <div class="editor-field">
             <%:Html.TextBoxFor(m => m.UserName, new { style = "width:350px;" })%>
        </div>
        <div class="editor-label">
             <%:Html.LabelFor(m => m.Password)%>
        </div>
        <div class="editor-field">
            <%:Html.PasswordFor(m => m.Password, new { style = "width:350px;" })%> 
        </div>
        <p>
            <input type="image" value="Log On" title="Log On"     src="../../Content/images/signinnew.png"/>
        </p>
</div>
<%} %>
主要观点:
<script type="text/javascript">
$(document).ready(function () {
    <%if (User.Identity.IsAuthenticated)
    { %>
        $("#logindata").hide();
    <%}
    else
    {%>
    $('#logindata').load("/Account/LogOn?returnUrl= <%:HttpContext.Current.Request.RawUrl%>"); 
    <%} %>
</script>
<%using (Html.BeginForm())
 { %>
<fieldset>
    <legend></legend>
     <div id="logindata" style="border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #CCCCCC;margin-bottom:10px;">
         **// I am loading the logon partial view here.**
     </div>
     <div class="editor-label">
        <%: Html.LabelFor(m => m.DeliveryInfo.Email)%>
     </div>
     <div class="editor-field">
        <%: Html.TextBoxFor(m => m.DeliveryInfo.Email)%>    
     </div>
     <div id="tohide">
     <div class="editor-label">
        <%: Html.LabelFor(m => m.DeliveryInfo.Password)%>
     </div>
     <div class="editor-field">
        <%: Html.PasswordFor(m=>m.DeliveryInfo.Password)%>    
     </div>
     <div class="editor-label">
        <%: Html.LabelFor(m => m.DeliveryInfo.ConfirmPassword)%>
     </div>
     <div class="editor-field">
        <%: Html.Password("ConfirmPassword")%>    
        <br />
        <%:Html.ValidationMessageFor(m=>m.DeliveryInfo.ConfirmPassword) %>
     </div>
     </div>
     <div class="editor-label">
        <%: Html.Label("Fullname")%>
     </div>
     <div class="editor-field">
        <%: Html.TextBoxFor(m => m.DeliveryInfo.Name)%>    
     </div>         
</fieldset>    
</div>
<%}%>