jquery - Date range without an inline datepicker -
i'm trying in thread: date range picker on jquery ui datepicker
but dont want datepicker inline, , code works inline datepicker.
i need datepicker when selecting #date1 or #date2 inputs.
i must easy, i'm stuck here , solutions find google plugins or inline datepicker.
jquery ui's datepicker dropdown default, example found little out of date think.
https://jsfiddle.net/groberts/z4j227h6/
$( "#from" ).datepicker({ defaultdate: "+1w", changemonth: true, numberofmonths: 3, onclose: function( selecteddate ) { $( "#to" ).datepicker( "option", "mindate", selecteddate ); } }); $( "#to" ).datepicker({ defaultdate: "+1w", changemonth: true, numberofmonths: 3, onclose: function( selecteddate ) { $( "#from" ).datepicker( "option", "maxdate", selecteddate ); }, beforeshowday: function (date) { var date1 = $.datepicker.parsedate($.datepicker._defaults.dateformat, $("#from").val()); var date2 = $.datepicker.parsedate($.datepicker._defaults.dateformat, $("#to").val()); return [true, date1 && ((date.gettime() == date1.gettime()) || (date2 && date >= date1 && date <= date2)) ? "dp-highlight" : ""]; }, });
the above code/fiddle shows few minor changes, can replicate functionality in dropdown.
hth.
Comments
Post a Comment