如何隐藏 CompareValidators 和正则表达式直到需要它们

发布于 2024-11-17 03:53:41 字数 205 浏览 5 评论 0原文

我用 c# 代码和一些 jscript 在 asp.net 中编写。

我正在使用 CompareValidators 和 RegularExpressions 来验证某些字段。除了一个问题之外,这工作正常。异常消息占用空间,这会扭曲表单的外观。我不希望该消息占用任何空间,除非确实需要显示它们。如果我要发回帖子,我可以通过使其可见和不可见来处理它。但在这种情况下我不知道如何处理。

I write in asp.net with c# code and some jscript.

I’m using CompareValidators and RegularExpressions to validate certain fields. This is working fine except for one problem. The exception messages take up room which is distorts the look of the form. I don’t want the message to take any room unless they actually need to be displayed. If I was issuing a post back I could handle it by making it visible and invisible. But in this case I don’t know how to handle it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初雪 2024-11-24 03:53:41

在验证器上将 Display 属性设置为 Dynamic。这将设置包含错误消息的范围以显示:无(当它不可见时不占用页面上的任何空间)。

Set the Display property to Dynamic on your validators. This will set the span that contains the error message to display:none when it is not visible which does not take up any room on the page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文