如何隐藏 CompareValidators 和正则表达式直到需要它们
我用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在验证器上将 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.