V
V
vitovt2012-01-19 16:56:47
JavaScript
vitovt, 2012-01-19 16:56:47

jquery datepicker date range selection?

Probably someone in his project faced such a task. We need a calendar with the ability to select a date range from and to, i.e. a person clicks once on the first date - this is the start date of the event, clicks in the same calendar a second time - this is the end of the event, and all dates between the start and end are highlighted.

Didn't find any solution for jQuery UI Datepicker although maybe I didn't search well. Perhaps there is no ready-made solution, but it is written in an elementary way and someone has already implemented this, maybe share information or an algorithm?

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
kuzemchik, 2012-01-19
@kuzemchik

jQuery UI Datepicker expects the input to store a date value, so two input fields are used to select the range.

S
sankir, 2012-01-19
@sankir

Jquery Datepicker:
Two input type="text" fields with id="from" and id="to"
Processing code By clicking inside the field, the calendar is called, if one of the fields is already selected, the date selection "before" or "after" is prohibited in the calendar » selected, whichever was selected first. Source
$(function() {
var dates = $( "#from, #to" ).datepicker({
onSelect: function( selectedDate ) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
});

V
Valery Chupurnov, 2014-01-09
@skoder

xdsoft.net/jqplugins/datetimepicker/#range maybe this?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question