use jquery datepicker and set the date selection below today. so no need to check it........... and still you want to test...then also you can check by jquery.......
Mark Answered if it helps - Good luck!
Cheers!
- Kaushik Patel
DateTime Today=DateTime.Now;
DateTime Birthday=Convert.ToDateTime(BirthdayTextBox.Text);
int Compare=DateTime.Compare(Today,Birthday);
if(Compare<0)
{
// Today is earlier
}
else
{
// Today is equal or later
}
alwaysonline
Member
174 Points
220 Posts
compare dates?
Jun 25, 2012 06:31 AM|LINK
i have a register form, where the user enters date of birth..if the user enters any future date, i need to give validation as invalid date..
so the date of birth that the suer enters shud eb less than current date, how to compare these both?
kaushik_tatv...
Contributor
2808 Points
500 Posts
Re: compare dates?
Jun 25, 2012 06:46 AM|LINK
Hello,
use jquery datepicker and set the date selection below today. so no need to check it........... and still you want to test...then also you can check by jquery.......
Cheers!
- Kaushik Patel
urenjoy
Star
12161 Points
1824 Posts
Re: compare dates?
Jun 25, 2012 06:52 AM|LINK
If you are using jQuery UI DatePicker, you can disable future date, check following:
http://jsfiddle.net/yetanothercoder/FAH4b/
If you want to validate server side, you can take idea from following:
http://www.a2zdotnet.com/View.aspx?Id=182#.T-gHGZGICCk
alwaysonline
Member
174 Points
220 Posts
Re: compare dates?
Jun 25, 2012 06:52 AM|LINK
$(selector).datepicker('option', {minDate: new Date(...), maxDate: new Date(...)});
vl the above code work, for jquery datepicker
alwaysonline
Member
174 Points
220 Posts
Re: compare dates?
Jun 25, 2012 06:57 AM|LINK
$(".mypicker").datepicker({
changeYear: true,
dateFormat: 'dd/mm/yy',
minDate: new Date('1990/01/01'),
maxDate: '-1d'
});
how to set max date here?
urenjoy
Star
12161 Points
1824 Posts
Re: compare dates?
Jun 25, 2012 06:59 AM|LINK
If you are using jQuery UI DatePicker, you can disable future date, check following:
http://jsfiddle.net/yetanothercoder/FAH4b/
If you want to validate server side, you can take idea from following:
http://www.a2zdotnet.com/View.aspx?Id=182#.T-gHGZGICCk
alwaysonline
Member
174 Points
220 Posts
Re: compare dates?
Jun 25, 2012 07:02 AM|LINK
$(selector).datepicker('option', {minDate: new Date(...), maxDate: new Date(2012/08/08)});
i used the above one in my view, but its not working
pradeepnt
Member
266 Points
154 Posts
Re: compare dates?
Jun 25, 2012 07:16 AM|LINK
Hi....
You can do it like:-
DateTime Today=DateTime.Now; DateTime Birthday=Convert.ToDateTime(BirthdayTextBox.Text); int Compare=DateTime.Compare(Today,Birthday); if(Compare<0) { // Today is earlier } else { // Today is equal or later }you can see it on :
http://msdn.microsoft.com/en-us/library/system.datetime.compare.aspx
Pradeep Narayan
kaushik_tatv...
Contributor
2808 Points
500 Posts
Re: compare dates?
Jun 25, 2012 07:26 AM|LINK
Please use following code...this works for me....
$(".mypicker").datepicker({ changeYear: true, dateFormat: 'dd/mm/yy', minDate: new Date('1990/01/01'), maxDate: '-1D' });MARK AS NASWER IF THIS WORKS..
Cheers!
- Kaushik Patel
alwaysonline
Member
174 Points
220 Posts
Re: compare dates?
Jun 25, 2012 07:30 AM|LINK