This is a migrated thread and some comments may be shown as answers.

Prevent selection of End Date to before Start Date

4 Answers 523 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Relative
Top achievements
Rank 1
Relative asked on 05 May 2009, 04:29 PM
Hi,
 If you have 2 date pickers / datetime pickers and they are "start date" and "end dates" and you want to prevent the user from choosing a date before or after the date set the opposite picker what are your options, I could probably code this using javascript using the mindate / maxdate and update as the user changes the values but has someone done this already?

I used to use Peter's Date Package and you could link two date pickers together and they would automatically adjust themselves depending on what you chose and prevent you from choosing a start date after the end date and vice versa without you having to write any new code.

L.

You can see what i am talking about here:

http://www.peterblum.com/DES/DemoDateTextBox.aspx

Scroll down to bottom:

Two DateTextBox fields can be linked together to support date range entry. This enforces that the start date never exceeds the end and vice versa. You can require a minimum number of days between the two dates and several other rules.






4 Answers, 1 is accepted

Sort by
0
Serrin
Top achievements
Rank 1
answered on 05 May 2009, 09:07 PM
Hey Leon,

To the best of my knowledge this isn't built in to the controls, but you can easily achieve the same results by adding a RadAjaxManager and having both controls update one another.  This way, if the lower DatePicker is given a higher selected date or if the higher DatePicker is given a lower selected date you can easily switch the date back (since the event arg e gives you both NewDate and OldDate, so you can easily revert it).

I'm sure you can do the same with Javascript, but I'm not as good with that so I'll leave that explanation up to someone else. :)
0
Relative
Top achievements
Rank 1
answered on 05 May 2009, 10:49 PM
Hi,

thanks for the reply.

yes, it can probably be done in javascript by checking the dates and doing a compare but i will have to work out all the scenarios. i would have thought this is a common requirement and there should be an example ready to copy and paste or implement what peter blum has done. i still have an old  licence for his stuff long before i became  a telerik convert but i want to keep it all telerik.

L
0
Accepted
Dimo
Telerik team
answered on 07 May 2009, 02:48 PM
Hi Leon,

Here is the requested example:

http://demos.telerik.com/aspnet-ajax/calendar/examples/datepicker/validation/defaultcs.aspx

Kind regards,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Relative
Top achievements
Rank 1
answered on 07 May 2009, 02:59 PM
OK, so just use built in asp.net validation - now i feel stooooopid :)

Thanks anyway, been busy putting this off!

L.

Tags
Calendar
Asked by
Relative
Top achievements
Rank 1
Answers by
Serrin
Top achievements
Rank 1
Relative
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or