首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >下午5点后2天,jQuery UI日期选择器重力表minDate

问下午5点后2天,jQuery UI日期选择器重力表minDate
EN

Stack Overflow用户
提问于 2015-10-25 23:03:51
回答 1查看 381关注 0票数 0

我正在尝试在wordpress中使用重力表单设置一个日期字段,如果当前时间是>= 5 am,则显示2天后的最小日期,不包括周末。

我找到了在Gravity Forms jQuery No Weekends上排除周末的解决方案,这是https://stackoverflow.com/users/1766031/ian-rogers的解决方案

代码语言:javascript
复制
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 });

});

因此,如果有人能帮我集成另一个解决方案,即如果当前时间是>= 5 5pm,则显示2天后的最小日期,我将不胜感激

EN

回答 1

Stack Overflow用户

发布于 2015-10-26 11:00:32

我想我自己得到了答案..下面是我使用的代码

代码语言:javascript
复制
<script type="text/javascript">
  jQuery(document).bind('gform_post_render', function(){
    jQuery("#input_1_1").datepicker('destroy');
    jQuery("#input_1_1").datepicker({ 
    minDate: new Date().getHours() >= 12 ? 2 : 0,
    beforeShowDay: jQuery.datepicker.noWeekends, minDate: '+1d',
   });
 });
</script>  
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33331177

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档