我已经使用重力形式的gform_post_render函数创建使用提前1天选择的minDate选项自定义日期选择:
http://www.gravityhelp.com/documentation/page/Gform_post_render
有没有办法,我可以排除周末呢? 我只希望用户能够选择与提前一天工作日。 我已经使用了试图beforeShowDay: $.datepicker.noWeekends
但似乎有发生冲突minDate
这里是我的表格: http://www.discountdumpsters.com/shop/30-yard-dumpster/
这里是我的代码:
<script type="text/javascript">
jQuery(document).bind('gform_post_render', function(){
// destroy default Gravity Form datepicker
jQuery("#input_1_1").datepicker('destroy');
// create new custom datepicker
jQuery("#input_1_1").datepicker({ defaultDate: '+1d', minDate: '+1d', gotoCurrent: true, prevText: '', showOn: 'both', buttonImage: 'http://www.discountdumpsters.com/wp-content/plugins/gravityforms/images/calendar.png', buttonImageOnly: true });
});
</script>
任何帮助,将不胜感激...谢谢!
其实我已经用你的代码上的外部JS文件,它与noweekends申报工作,甚至
jQuery(document).bind('gform_post_render', function(){
// destroy default Gravity Form datepicker
jQuery(".datepicker").datepicker('destroy');
// create new custom datepicker
jQuery(".datepicker").datepicker({
defaultDate: '+1d',
minDate: '+1d',
gotoCurrent: true,
prevText: '',
showOn: 'both',
buttonImage: '/wp-content/themes/teloaggiustoio/images/calendar_icon.png',
buttonImageOnly: true,
beforeShowDay: $.datepicker.noWeekends
}); });
意识到我根本没有回答这个问题。 这里是为我工作的最终代码:
jQuery(document).bind('gform_post_render', function(){
// destroy default Gravity Form datepicker
jQuery("#input_1_1").datepicker('destroy');
// create new custom datepicker
var oneWorkingDays = new Date();
var adjustments = [0, 1, 1, 1, 1, 1, 0]; // Offsets by day of the week
oneWorkingDays.setDate(oneWorkingDays.getDate() + 1 + adjustments[oneWorkingDays.getDay()]);
jQuery("#input_1_1").datepicker({ beforeShowDay: jQuery.datepicker.noWeekends, minDate: '+1d', gotoCurrent: true, prevText: '', showOn: 'both', buttonImage: '/wp-content/plugins/gravityforms/images/calendar.png', buttonImageOnly: true });
});