Html.ValidationSummary(假,"消息")总是显示,即使在页面加载 [英] Html.ValidationSummary(false, "message") is always showing, even on page load

查看:605
本文介绍了Html.ValidationSummary(假,"消息")总是显示,即使在页面加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的客户端验证,我想,当我有一个错误下面的信息只显示。我试图用这个的一般错误的情况下,任何领域是无效的。
目前

I am using client side validation and I would like the message below to show only when I have an error. I am trying to use this a general error in case any field is invalid.
Currently

「*为必填字段

总是显露出即使验证了。

is always showing even before validation.

<%: Html.ValidationSummary(false, "* denotes required field.")%>

我使用的模型绑定到客户端和MVC执行验证。

I am using model binding to perform validation on client side and MVC.

推荐答案

如果您在浏览器检查验证摘要文本使用开发工具,你会看到它有类的验证,汇总有效时,很清楚,但验证,汇总错误当有形式的错误。

If you use a developer tool in your browser to inspect the validation summary text you'll see that it has the class 'validation-summary-valid' when it is clear but 'validation-summary-errors' when there are form errors.

因此​​,只需创建一个CSS规则如下:

Therefore, just create a css rule as follows;

.validation-summary-valid
{
display:none;
}

和所有应该是好的。

这篇关于Html.ValidationSummary(假,&QUOT;消息&QUOT;)总是显示,即使在页面加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆