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

From / To date issue

3 Answers 62 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Taj
Top achievements
Rank 1
Taj asked on 27 Jun 2011, 08:13 AM
Using datepicker to takr "To" and "From" date inputs in a MVC view . I need to make sure that users can't select To date value prior to From value. I am doing as follows


<%: Html.Telerik().DatePicker().Name("From").OpenOnFocus(true)%> 

<%: Html.Telerik().DatePicker().Name("To").Min(Model.From).OpenOnFocus(true)%> 

Getting an error on load of the page:

Server Error in '/' Application.

"date" cannot be null or empty.


I understand it's happening because my "To" field is empty, but what is the walk-around?

3 Answers, 1 is accepted

Sort by
0
Taj
Top achievements
Rank 1
answered on 28 Jun 2011, 08:39 AM
Hi There,

Still waiting for a solution
0
Demon
Top achievements
Rank 1
answered on 28 Jun 2011, 08:48 AM
Hi,

Even if the FROM field is not empty, it is not reasonable to set its value as a min value for the TO field, because both can be changed client-side.

You should implement server validation similar to this one...

http://demos.telerik.com/aspnet-mvc/datepicker/servervalidation

and also client validation by using the components' change event.

http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-datepicker-client-api-and-events.html#OnChange
0
Taj
Top achievements
Rank 1
answered on 29 Jun 2011, 06:20 AM
Thanks Demon for your reply.

I think I need to do as follows
1. if FROM date is empty, disable TO date
2. On Change of FROM date, enable TO date and  set TO date's Min value to FROM date

How can I do that?

It will be a good user experience if I can do the whole thing on client side.
Tags
Date/Time Pickers
Asked by
Taj
Top achievements
Rank 1
Answers by
Taj
Top achievements
Rank 1
Demon
Top achievements
Rank 1
Share this question
or