mominsamir / smDateTimeRangePicker

Angular Material Date Picker, DateTime Picker, Date Range Picker, Date Time range picker
http://mominsamir.github.io/smDateTimeRangePicker/
MIT License
130 stars 50 forks source link

date range picker end date validation problem. #178

Closed Devarajsingh89 closed 5 years ago

Devarajsingh89 commented 6 years ago

Hi,

smDateTimeRangePicker if i am selecting start date as for example "15-Mar-2018 01:01 AM" and if want to select end date as "15-Mar-2018 6:30 PM" its not allowing, the 15 in end date is disabled.

rahimnagori commented 5 years ago

Hello @oscar09 , How are you? I need to apply dynamic validations on end date. Could you please help me with it?

oscar09 commented 5 years ago

what do you mean by dynamic validations? how are you planning to use it?

rahimnagori commented 5 years ago

There is an option max-date=moment() which only allow selecting max date as today's date for the case of Range Picker. I need to apply max date validation for all the cases : Today Week Month Range How to achieve this?

rahimnagori commented 5 years ago

And one more thing can I display only one option in date range picker? image Marked in blue.

rahimnagori commented 5 years ago

I got something : image

oscar09 commented 5 years ago

The issue has been fixed. You should be able to use the custom list in the followign way:

vm.customList = [
    {
        position: 0,
        label: 'Holy Week',
        startDate: moment('2019-04-14'),
        endDate: moment('2019-04-20')
    }

];

html attr: custom-list="vm.customList"

and you will get something like this:

image

oscar09 commented 5 years ago

max-date property grays out the dates after the set max date. If you need to run specific validations (if the selected day is a weekend for example) you could do it in the oRangeSelect method. The returned objects are moment objects and it already has methods to check those kind of constraints.

max-date should take the date as moment or as max-date="11-10-2016" (assuming that you set the format as DD-MM-YYYY)

rahimnagori commented 5 years ago

I'm trying to apply max date validation as : Controller : $scope.maxDate = 'MM/DD/YYYY'; View File : max-date="moment(maxDate)" Now it is not working. Any idea?

oscar09 commented 5 years ago

Moment js takes a date string and converts it to moment object. It should be able to parse a date that comes with the format mm/dd/yyyy. Which date are you passing ?