我可以在主视图上使用验证来停止模式弹出窗口吗?

时间:2018-03-14 14:30:52

标签: asp.net-mvc asp.net-core bootstrap-modal

我有一个ASP.NET Core MVC应用程序。这是登录视图,弹出模式部分并允许您提交密码重置。我现在已将其部署到我的测试框,当我尝试重置密码时,它似乎在登录表单上运行验证。我在重置弹出窗口中输入了一个电子邮件地址,我点击提交但后台的登录页面获得了“这个字段是必需的”#39;两个输入框上的验证警报。如果我填写它们实际上可以通过它并提交重置密码请求。有办法解决这个问题吗?

<div class="login-body">
<div class="container">
    <form method="post" class="form-signin" action="/Account/Login?returnurl=%2F">
        <h2 class="form-signin-heading">Sign In</h2>
        <div class="login-wrap">
            <div class="user-login-info">
                <input type="email" class="form-control" placeholder="Email" autofocus data-val="true" data-val-email="Please, provide a valid email address." data-val-required="This field is required." id="Email" name="Email" value="" />
                <span class="text-danger field-validation-valid" data-valmsg-for="Email" data-valmsg-replace="true"></span>
                <input type="password" class="form-control" placeholder="Password" data-val="true" data-val-required="This field is required." id="Password" name="Password" />
                <span class="text-danger field-validation-valid" data-valmsg-for="Password" data-valmsg-replace="true"></span>
            </div>

            <label class="checkbox">
                <input type="checkbox" data-val="true" data-val-required="The Remember me? field is required." id="RememberMe" name="RememberMe" value="true" /> Remember me
                <span class="pull-right">
                    <a data-toggle="modal" href="#forgotPassModal">Reset Password</a>
                </span>
            </label>
            <button class="btn btn-lg btn-login btn-block" type="submit">Sign In</button>

            <div class="registration">
                Don't have an account yet?
                <a href="/Account/Register">Create an account</a>
            </div>
        </div>

        <!-- Modal -->

    <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="forgotPassModal" class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">Reset Password</h4>
                </div>
                <div class="modal-body">
                    <p>Enter your e-mail address below to reset your password.</p>
                    <input type="text" name="email" placeholder="Email" autocomplete="off" class="form-control placeholder-no-fix">

                </div>
                <div class="modal-footer">
                    <button data-dismiss="modal" class="btn btn-default" type="button">Cancel</button>
                    <button class="btn btn-success" method="post" formaction="/Account/ForgotPassword">Submit</button>

                </div>
            </div>
        </div>
    </div>

0 个答案:

没有答案