I want to filtering the date between two textbox, my problem is when I pick the date on the second box, it doesnt include the date that i choose.
the code for textbox
<label for="from">From</label>
<input type="text" id="from" />
<label for="to">To</label>
<input type="text" id="to" />
for script the datepicker
//function for datepicker and date range
$(function() {
$( "#from" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
onSelect: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
}
});
$( "#to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
onSelect: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
}
});
});
updated
$from = new Date(Date.parse($("#from").datepicker('getDate')));
$to = new Date(Date.parse($("#to").datepicker('getDate')));
this is how it defined
You should just access the value directly:
if ($("#from").val()) {
$filter.push({field: "DateEnrolled", operator: ">=", value: $("#from").val()});
}
if ($("#to").val()) {
$filter.push({field: "DateEnrolled", operator: "<=", value: $("#to").val()});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.