CompareValidator 与 aspCalendar
我的网站上有两个 aspCalendar 控件。我想执行验证(日历 2 的日期应该大于日历 1 的日期)。
<asp:CompareValidator ID="CompareValidator1" runat="server"
ErrorMessage="CompareValidator"
ControlToValidate="Calendar2"
Operator="GreaterThanEqual"
Type="Date"
ControlToCompare="Calendar1"
/>
有很多验证的示例,但使用 ControlToValidate 作为文本框或标签,更复杂的控件怎么样,有什么方法可以告诉我必须使用该控件的哪个属性?
也许客户端验证?但如何做到这一点呢?
感谢您的帮助
I ve two aspCalendar controls on the website. I would like to perform validation (date from Calendar2 should be greater then date from Calendar 1).
<asp:CompareValidator ID="CompareValidator1" runat="server"
ErrorMessage="CompareValidator"
ControlToValidate="Calendar2"
Operator="GreaterThanEqual"
Type="Date"
ControlToCompare="Calendar1"
/>
There are a lot examples of validation but with ControlToValidate as textBox or label, What about more complex Controls, is there any way I can tell which property from that control has to be used?
Maybe Client side validation ? But how to do this ?
Thanks for help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用自定义验证器,它可以让您完全控制验证发生的方式。要验证的控件可能不接受日历;但是,您可以将其指向文本框,但在 servervalidate 函数的幕后验证您的日历,因此这是使验证器与日历等控件一起使用的解决方法。
您可以使用客户端验证,但这取决于您要验证的内容以及验证的容易程度;日历控件有很多标记,所以这可能很难......
HTH。
I would recommend using a customvalidator, which gives you complete control over the way the validation occurs. The control to validate may not accept the calendar; however, you can point it to a textbox, but behind the scenes in the servervalidate function validate your calendars, and so that is a workaround to making the validators work with controls like the calendar.
You could use client validation, but it depends on what you are trying to validate and how easy it would be; there is a lot of markup with the calendar control, so that might be hard...
HTH.