admin管理员组文章数量:1279114
- I need to set the "start date" to +1 day from the current day.
- And +3 days from the "start date" for the "end day"
- (optional) Highlight the trailing days
Fiddle can be found here:
Thanks!
- I need to set the "start date" to +1 day from the current day.
- And +3 days from the "start date" for the "end day"
- (optional) Highlight the trailing days
Fiddle can be found here: http://jsbin./icuduv/1
Thanks!
Share Improve this question asked Oct 16, 2012 at 13:03 Pennf0lioPennf0lio 3,8948 gold badges48 silver badges73 bronze badges3 Answers
Reset to default 6well you can simply do it like this
var d = new Date(); d.setDate( d.getDate() + 1 );
$('#txtStartDate').datepicker('setDate', d);
d = new Date(); d.setDate( d.getDate() + 4 );
$('#txtEndDate').datepicker('setDate', d);
i have updated your demo as well have a look Here
for highlighting dates you can use the beforeShowDay event. It will get called for each date that needs to be shown in the calendar.
Get the date values using something along these lines:
var startDate = new Date();
var endDate = new Date();
startDate.setDate(today.getDate()+1);
endDate.setDate(startDate.getDate()+3);
$("#startDateInput").val(startDate.toString('MM/dd/yyyy'));
$("#endDateInput").val(endDate.toString('MM/dd/yyyy'));
This question could help with the highlighting:
Highlight dates in specific range with jQuery's datepicker
Maybe you can try this one
$(function() {
var $defaultDate = new Date();
$defaultDate.setDate( $defaultDate.getDate() + 1 );
$('#txtStartDate').datepicker({defaultDate: $defaultDate}).val(($defaultDate.getMonth()+1) + '/' + $defaultDate.getDate() + '/' + $defaultDate.getFullYear());
$defaultDate.setDate( $defaultDate.getDate() + 3 );
$('#txtEndDate').datepicker({defaultDate: $defaultDate}).val(($defaultDate.getMonth()+1) + '/' + $defaultDate.getDate() + '/' + $defaultDate.getFullYear());
});
本文标签: javascriptHow to set date range in jQuery Datepicker and set it as a default valueStack Overflow
版权声明:本文标题:javascript - How to set date range in jQuery Datepicker and set it as a default value? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741272769a2369559.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论