我应该如何验证文本框的日期不超过当前日期 [英] how should i validate a textbox not to tk date more than the current date
本文介绍了我应该如何验证文本框的日期不超过当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该如何验证文本框的日期不超过当前日期
how should i validate a textbox not to tk date more than the current date
推荐答案
请参阅此
http://forums.asp.net/t/1373420.aspx/1 [ ^ ]
http://forums.asp.net/t/1357242.aspx [
Refer this
http://forums.asp.net/t/1373420.aspx/1[^]
http://forums.asp.net/t/1357242.aspx[^]
您可以使用日期比较方法是时候检查日期了.
例如:
you can use the Compare method of date time to check the date.
for example:
DateTime date1 = Convert.ToDateTime(txtbox1.Text);
DateTime dt = DateTime.Now;
int result = DateTime.Compare(date1, dt );
string relationship;
if (result < 0)
relationship = "is earlier than";
else if (result == 0)
relationship = "is the same time as";
else
relationship = "is later than";
尝试一下:
http://stackoverflow. com/questions/1070866/can-i-do-a-date-check-on-a-textbox-with-a-onblur-event [ http: //stackstackflow.com/questions/6133539/how-can-i-validate-the-date-is-not-the-future-date-in-net-c-sharp [
Try this:
http://stackoverflow.com/questions/1070866/can-i-do-a-date-check-on-a-textbox-with-a-onblur-event[^]
Refer it also
http://stackoverflow.com/questions/6133539/how-can-i-validate-the-date-is-not-the-future-date-in-net-c-sharp[^]
这篇关于我应该如何验证文本框的日期不超过当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文