Prevent selection of End Date to before Start Date

5 posts, 1 answers
  1. Relative
    Relative avatar
    31 posts
    Member since:
    May 2004

    Posted 05 May 2009 Link to this post

    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.






  2. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 05 May 2009 Link to this post

    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. :)
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Relative
    Relative avatar
    31 posts
    Member since:
    May 2004

    Posted 05 May 2009 Link to this post

    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
  5. Answer
    Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 07 May 2009 Link to this post

    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.
  6. Relative
    Relative avatar
    31 posts
    Member since:
    May 2004

    Posted 07 May 2009 Link to this post

    OK, so just use built in asp.net validation - now i feel stooooopid :)

    Thanks anyway, been busy putting this off!

    L.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017