如何在点击asp.net mvc中的文本框时隐藏验证消息?

时间:2017-07-14 10:03:13

标签: javascript asp.net model-view-controller

当我试图隐藏文本框中的验证消息时,它没有隐藏,请你帮帮我

<div class="col-md-10">
                    @Html.TextBoxFor(m => m.Email, new { @class = "form-control", @autocomplete = "off", onclick = "clearValidation()" })
                    @Html.ValidationMessageFor(m => m.Email, "", new { @style = "color:white; font-weight:normal; margin-left:-155px;" })
                </div>


<script>

function clearValidation() {
            document.getElementsByClassName("validation-summary-errors").style.color = "#ff0000";
        }
</script>

1 个答案:

答案 0 :(得分:0)

使用此 -

$.fn.clearValidation= function () {
    $(this).each(function() {
        $(this).find(".field-validation-error").empty();
        $(this).trigger('reset.unobtrusiveValidation');
    });
};