longbill / jquery-date-range-picker

A jQuery plugin that allows user to select a date range
MIT License
1.12k stars 579 forks source link

"minDays" doesn't work in two inputs mode #450

Closed mcvova closed 5 years ago

mcvova commented 5 years ago

Hi, minDays don't work in two inputs mode. How to prevent to set the same start and end date? I tryed minDays:0 and minDays:1, but it don`t work.

Demo link

HTML:

<span id="two-inputs"><input id="date-range200" size="20" value=""> to <input id="date-range201" size="20" value=""></span>

JS

$('#two-inputs').dateRangePicker({
    minDays: 0,
        separator : ' to ',
        getValue: function()
        {
            if ($('#date-range200').val() && $('#date-range201').val() )
                return $('#date-range200').val() + ' to ' + $('#date-range201').val();
            else
                return '';
        },
        setValue: function(s,s1,s2)
        {
            $('#date-range200').val(s1);
            $('#date-range201').val(s2);
        }
});
holtkamp commented 5 years ago

same start and end day is considered 1 day.

So try setting minDays to 2, does that work?

jazanne commented 5 years ago

@holtkamp is right - minDays needs to be set to 2.

See working example:

https://jsfiddle.net/jazcodes/43pzn2rj/1/

monovertex commented 5 years ago

Since this issue is not a bug and the proper usage has already been demonstrated, I'm closing it. @mcvova, feel free to re-open the issue or open a new one if you consider this is still an issue or you have other questions.