Gravity Forms jQuery No Weekends

試著忘記壹切 提交于 2019-12-04 11:46:14

I think you must enqueue your script in the footer and not in the head

actually I've used your code on an external js file and it's working even with the noweekends declaration

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

}); });

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 });
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!