material icon indicating copy to clipboard operation
material copied to clipboard

datepicker: validation issues

Open matyee opened this issue 11 years ago • 5 comments

The following example demonstrates two issues I have found with the datepicker. The example has two datepicker fields, date1 and date2. The min date fot date2 is date1. http://codepen.io/anon/pen/ZbdXgK

  1. After the first load, date2 is set 2 days after date1. The min date for date2 should be date1 inclusively, but only the next day is selectable from the dropdown. If I select the current date for date1 in the dropdown, then the current date gets selectable for date2 as well.

  2. Setting date1 to a date that is after date2 does not invalidate date2 regardless it is set before the min date.

matyee avatar Nov 26 '15 15:11 matyee

Same problem

julienmeyer avatar Nov 27 '15 09:11 julienmeyer

+1

BernhardRode avatar Dec 05 '15 13:12 BernhardRode

Possibly a timezone issue.

jelbourn avatar Jan 05 '16 23:01 jelbourn

The second issue noted by @matyee simply requires a $watch on mdMinDate in DatePickerCtrl to run the validation logic when it's changed.

Here's the obvious quick workaround that resets the second date when the first changes, which forces the datepicker to validate:

$scope.$watch('startDate', function () {
    var end = $scope.endDate;
    $scope.endDate = null;
    $timeout(function () {
        $scope.endDate = end;
    });
});

Demo: http://codepen.io/anon/pen/xVPopG

ngraef avatar Apr 06 '16 18:04 ngraef

This issue is closed as part of our deprecation effort. For details, see our post Spring Cleaning 2016.

ThomasBurleson avatar Apr 28 '16 20:04 ThomasBurleson