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

[Solved] Setting Minimum values on date pickers

3 Answers 51 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.
Jimmy
Top achievements
Rank 1
Jimmy asked on 14 Oct 2011, 01:31 PM
I have a telerik datepicker Date0 which when selected should go and set the min value if Date1

Ideally I do not want the value to change unless it is invalid then I would like it to clear Date2.

Then I want focus to be the next control rather than Date1 having the control.

My code is below.

The only way I can get Next Field to have focus is to disable Date1.

Even when Date1 is a valid date it gets overwritten with the new Date in Date0.

Is there a way of making this work?

function onDate0Change(e) {
            var value = $('#Date1').data("tDatePicker").value();
            $('#Date1').data("tDatePicker").min(e.value);
            if (value != null) {
                if (value > e.value) {
                    $('#Date1').data("tDatePicker").value("");
                }
                else {
                    $('#Date1').val($.telerik.formatString('{0:dd/MM/yyyy}', value));
                    $('#Date1').data("tDatePicker").value($.telerik.formatString('{0:dd/MM/yyyy}', value));
                }
            }
            else {
                $('#Date1').data("tDatePicker").value("");
            }
            $('#NextField').focus();
        }

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 17 Oct 2011, 09:45 AM
Hello Jimmy,

 
It is unclear what your goal exactly is. Could you please send us a simple test project which replicates the issue? Thus I will be able to review it locally and advice you further.

Regards,
Georgi Krustev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Jimmy
Top achievements
Rank 1
answered on 26 Oct 2011, 07:50 PM
Please see attached project.

I would like my textbox control to have focus after setting the min on the 2nd datepicker control.

Also is it possible to turn off parsing on these datapickers.

- Jimmy
0
Georgi Krustev
Telerik team
answered on 28 Oct 2011, 12:08 PM
Hello Jimmy,

 
Here is a quote of the answer to the support ticket open on the same matter:

Straight onto your questions:

#1:  The Date1 is set to Date0 min value only if the Date1 is empty. I agree with you that this is not the expected behavior. We decide to not set the value of the datepicker to its min value if the selected value is null. The fix will be included in the next official release of Telerik Extensions for ASP.NET MVC. 

For you convenience I have attached the modified test JavaScript file.

#2:
There was a bug related with setting min value of the datepicker and reassigning of the shared calendar. This is fixed in the attached file. The fix will be included in the next release. Nevertheless you will need to focus String0 using SetTimeout, because we try to return the focus to the datepicker's INPUT element after calendar is clicked. Here is the modified onDate0Change event handler:

Copy Code
<script type="text/javascript">
    function onDate0Change(e) {
        var value = $('#Date1').data("tDatePicker").value();
        $('#Date1').data("tDatePicker").min(e.value);
        setTimeout(function() {
            $("#String0").focus();
        }, 100);
    }
</script>

The DatePicker parse method handles the parsing of the date. You can override it and introduce your own date parsing.

Kind regards,
Georgi Krustev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Date/Time Pickers
Asked by
Jimmy
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Jimmy
Top achievements
Rank 1
Share this question
or