Open few2539 opened 5 years ago
Hi, please provide a codepen with a working example which demonstrates this so we can say what the best solution is.
window.free_pickadate = {
init: function () {
var from_$input = $('#input_from').pickadate(),
from_picker = from_$input.pickadate('picker')
var to_$input = $('#input_to').pickadate(),
to_picker = to_$input.pickadate('picker')
// from_picker.set('min',true)
from_picker.set('min', true)
// Check if there’s a “from” or “to” date to start with.
if (from_picker.get('value')) {
to_picker.set('min', from_picker.get('select'))
}
if (to_picker.get('value')) {
from_picker.set('max', to_picker.get('select'))
}
// When something is selected, update the “from” and “to” limits.
},
update: function () {
var from_$input = $('#input_from').pickadate(),
from_picker = from_$input.pickadate('picker')
var to_$input = $('#input_to').pickadate(),
to_picker = to_$input.pickadate('picker')
from_picker.on('set', function (event) {
if (event.select) {
to_picker.set('min', from_picker.get('select'))
} else if ('clear' in event) {
to_picker.set('min', false)
}
})
to_picker.on('set', function (event) {
if (event.select) {
from_picker.set('max', to_picker.get('select'))
} else if ('clear' in event) {
from_picker.set('max', false)
}
})
},
onReady: function () {
$("#input_from").pickadate({
formatSubmit: 'dd/mm/yyyy',
// formatSubmit: '['dd','mm','yyyy']',
hiddenName: true
});
$("#input_to").pickadate({
formatSubmit: 'dd/mm/yyyy',
hiddenName: true
});
window.free_pickadate.init();
window.free_pickadate.update();
},
}
Can you combine this with some html and provide a full codepen.com example?
https://codepen.io/phuridate-thepnarong/pen/KJOExE
honestly sorry sir for my coming late .
example i pick 20/01/2019 in the first one. and second date i would like to pick date between 20-25/01/2019 i used set.max but it is relative on today. Thx for helping