ASP CompareValidator 和不提交表单
我有一个文本框和一个提交按钮。文本框是一个日期输入字段。
附加到它,我有一个类型设置为“日期”的比较验证器。它确实验证并显示错误消息。
问题是,用户仍然可以单击提交按钮。我想阻止这种情况发生。如果用户输入了类似 03/hello/2011 的内容,他或她应该无法提交表单。
我怎样才能做到这一点?
有什么想法吗?
谢谢,
杰森
I have a textbox and a submit button. The textbox is a date-entry field.
Attached to it, I have a compare validator with the type set to "date". It does validate and show an error message.
Problem is, the user can still click on the submit button. I'd like to prevent that. If the user has entered something like 03/hello/2011, he or she should not be able to submit the form.
How can I accomplish this?
Any ideas?
Thanks,
Jason
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将验证器和提交按钮关联到单个验证组中。他们都有属性验证组。为两个控件的属性提供名称(例如 pageValidation)。
Associate the validator and the submit button in a single validation group. Both of them have the property validation group. Provide a name say pageValidation to both the control's property.
我自己也遇到过这个问题,当用户单击提交按钮时,验证错误的页面仍然可以继续提交。
你可以做的是这样的:
I've encountered this problem myself, that a page with validation errors can still continue on to submission when the user clicks the submit button.
What you can do is something like this :