在弹出窗口中禁用或删除Dataannotation

时间:2014-03-11 05:42:25

标签: javascript jquery asp.net asp.net-mvc-4

我有一个包含点击按钮的按钮,我正在填充一个包含两个输入类型密码输入的窗口。我已经在所有输入上使用了验证工作非常好现在我的问题是当我关闭此窗口时并再次重新打开验证范围仅保留在那里。如何删除或禁用此功能? 请分享解决方案。 我的代码如下:

 @model Invoice.Models.ViewModels.PasswordManagement.PasswordViewModel
    @using (Html.BeginForm("ChangePassword", "Auth", FormMethod.Post, new { @class = "form-horizontal Password" }))
        {
            @Html.ValidationSummary(true)
            <div class="control-group">
                <label class="control-label">
                    New Password
                </label>
                <div class="controls">
                    @Html.PasswordFor(m => m.OldPassword)<br/>
                    @Html.ValidationMessageFor(m => m.OldPassword)
                </div>
            </div>

            <div class="control-group">
                <label class="control-label">
                    Confirm Password
                </label>
                <div class="controls">
                    @Html.PasswordFor(m => m.NewPassword)<br/>
                    @Html.ValidationMessageFor(m => m.NewPassword)
                </div>
            </div>

            <center style="margin-left: 25px;">
                <input type="submit" class="btn btn-primary" value="Save" style="width:68px;" />
                <input type="button" class="k-button" id="PasswordWindowClose" value="Cancel" style="width:65px;" />
            </center>


        }
    <script>
        $(document).ready(function () {
            $("#PasswordWindowClose").on('click', function () {
                $('#PasswordWindowClose').parents('.k-window-content').data('kendoWindow').close();
                var validator = $(".Password").data('validator');
                    validator.settings.ignore = "input[type=password]";
            });
        });
    </script>

1 个答案:

答案 0 :(得分:0)

我在这里得到了解决方案,我正在添加它。

$('.input-validation-error').addClass('input-validation-valid');
$('.input-validation-error').removeClass('input-validation-error');
$('.field-validation-error').addClass('field-validation-valid');
$('.field-validation-error').removeClass('field-validation-error');
$('.validation-summary-errors').addClass('validation-summary-valid');
$('.validation-summary-errors').removeClass('validation-summary-errors');