本文介绍了重力形式jQuery No Weekends的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Gravity Forms中的gform_post_render函数使用minDate选项创建了一个自定义日期选择器,以提前选择1天:

I have used the gform_post_render function in Gravity Forms to create a custom datepicker using the minDate option for selection of 1 day in advance:

http://www.gravityhelp.com/documentation/page/Gform_post_render

有没有一种方法可以排除周末?我只希望用户能够选择提前一天的工作日.我尝试使用beforeShowDay: $.datepicker.noWeekends,但似乎与minDate

Is there a way that I can exclude weekends? I only want the user to be able to select weekdays with one day ahead. I have tried using the beforeShowDay: $.datepicker.noWeekends but that seems to conflict with minDate

这是我的表格: http://www.discountdumpsters.com/shop/30码垃圾箱/

这是我的代码:

<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>

任何帮助将不胜感激...谢谢!

Any help would be appreciated...thanks!

推荐答案

意识到我从未回答过这个问题.这是对我有用的最终代码:

Realized I never answered this question. Here is the final code that worked for me:

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 });
});

这篇关于重力形式jQuery No Weekends的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 22:29