amsul / pickadate.js

The mobile-friendly, responsive, and lightweight jQuery date & time input picker.
http://amsul.ca/pickadate.js
MIT License
7.7k stars 1.01k forks source link

Dynamically set min & max on onSet #690

Open S8nsick66 opened 9 years ago

S8nsick66 commented 9 years ago

Hello!

I have 2 date pickers, one is for start date and one is for end date. When I change start date, I want to set min on end date to that value. So users can't set an end date that is before the start date.

onSet: function(thingSet) {
    if(thingSet.select){
        end_picker.set({
            'min': start_picker.get('value'),
            'max': false
        });
    }
}

I have verified that start_picker and end_picker are correctly set (onStart). I have tried calling render, start and stop after setting but min is not changed.

Is there a way to accomplish what I want?

Thanks in advance! /Dennis

leph24 commented 9 years ago

233

akash-suthar commented 8 years ago

$('.datepicker').on('change', function () { if ($(this).attr('id') === 'datefrom') { alert($(this).val()) $('#dateto').pickadate('picker').set('min',$(this).val()); } if ($(this).attr('id') === 'dateto') { $('#datefrom').pickadate('picker').set('max',$(this).val()); } });

4ndro1d commented 7 years ago

Not working for me

ompradeep commented 7 years ago

@oozrafa #233 working for me

Thanks!