联系表格7 Datepicker,日期范围在2个日期之间 [英] Contact form 7 Datepicker, date range between 2 dates

查看:191
本文介绍了联系表格7 Datepicker,日期范围在2个日期之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的WordPress联系表单中有两个日期字段。开始日期和结束日期。这些字段将是Contact Form 7 Datepicker插件的日期戳。
当访客选择了开始日期时,他应该只能选择4天后的开始日期。



只能使用contact form 7表单创建者才能实现此目的?

解决方案

这是我在联系表单7中输入的语法。

 开始日期章程*:
[date * date-start date-format:MM_d_yy]

结束日期章程*:
[日期*日期结束日期格式:MM_d_yy]



我将这个代码添加到Wordpress主题的函数文件的末尾。

  function calendar_js(){
?>
< script>
jQuery(function($){
var start = $('。date-start input')。first();
var end = $('。date-end input' .first();

start.on('change',function(){
var start_date = $(this).datepicker('getDate');
start_date。 setDate(start_date.getDate()+ 3);
end.datepicker('option','minDate',start_date);
});
});
< / script>
<?php
}
add_action('wp_footer','calendar_js');

现在第二个日期选择器必须至少4天后才是第一个日期选择器。 >

I would like to have two date field in my Wordpress contact form 7. A start-date and an end-date. The fields will be datepickers from the "Contact Form 7 Datepicker" plugin. When visitor has selected a start-date he should only be able to select an end date that is 4 days later then the start-date.

How can I achieve this by only using the "contact form 7" form creator?

解决方案

This is the syntax I put in the "contact form 7".

Start date charter*:
[date* date-start date-format:MM_d_yy]

End date charter*:
[date* date-end date-format:MM_d_yy]

And I added this code to the end of the functions file of the Wordpress theme.

function calendar_js(){
    ?>
    <script>
    jQuery(function($){
            var start = $('.date-start input').first();
            var end = $('.date-end input').first();

            start.on('change', function() {
                    var start_date = $(this).datepicker('getDate');
                    start_date.setDate(start_date.getDate() + 3);
                    end.datepicker('option', 'minDate', start_date);
            });
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'calendar_js');

Now the second date picker must be at least 4 days later then the first date picker.

这篇关于联系表格7 Datepicker,日期范围在2个日期之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆