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

[Solved] Clicking out doesn't validate the input

1 Answer 21 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.
Ricardo
Top achievements
Rank 1
Ricardo asked on 28 Jul 2011, 08:08 PM
Hello guys.

I was testing the DateTime Picker example and I may have found a problem. In the first input, clear the date and type "1" then click somewhere else. The input will appear now as invalid (red color). Now click again in the input and just click out, without changing the value. The input will be now marked as valid (no red color).

I think the reason why this happens is because the event used is change(), not the focusout() or blur() (or something like that). There's some way I can validate the input everytime the user lefts the field? I was thinking about wrapping the focusout() directly to the change() event by hand using jQuery. What do you guys think?


Edit: a temporary solution...
Edit2,3: fixed a few problems in the code below.

// Save the close function somewhere.
$(this).data('tDatePicker').dateView.oldClose = $(this).data('tDatePicker').dateView.close;
 
// On close, update the date to make sure it's valid. So if the user type gargabe in the field and click out (which triggers the close), the field will be red (which means invalid date).
var that = this;
$(this).data('tDatePicker').dateView.close = function () {
    $(that).data('tDatePicker')._update($(that).val());
    $(that).data('tDatePicker').dateView.oldClose();
};
 
// When we lost focus, and if the calendar is not open, revalidate.
$(this).focusout(function () {
    if (!$(this).data('tDatePicker').dateView.isOpened()) {
        $(this).data('tDatePicker')._update($(this).val());
    }
});


Thanks a lot,

Ricardo

PS: I've been using these extensions in the last 2 or 3 weeks and they're awesome! :)

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 01 Aug 2011, 12:55 PM
Hello Ricardo,

 
This is a known issue, which I am glad to inform is already addressed. The fix of this problem will be included in the next internal build of Telerik Extensions for ASP.NET MVC.

Kind regards,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Tags
Date/Time Pickers
Asked by
Ricardo
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or