-
AuthorPosts
-
June 4, 2019 at 6:41 pm #1107223
Helo all,
Is it possible to choose a span of dates when using the date picker in a contact form as opposed to just choosing one day? For instance booking a rental between a span of days instead a single day. Let me know when you get a minute. Thanks!
June 4, 2019 at 8:01 pm #1107254I did find this article but it looks like things have changed since then. Can you give me an updated on how to achieve this? Thanks!
June 5, 2019 at 10:10 am #1107457Hi,
Unfortunately such customization would be out of the scope of our support however we can point you in right direction.
Please firstly make sure that you are using a child theme – https://kriesi.at/documentation/enfold/using-a-child-theme/
– Please copy unmodified enfold/framework/php/class-form-generator.php file and paste it inside enfold-child folder and find following at the top and remove it (please do not remove PHP opening tag)
if ( ! defined( 'AVIA_FW' ) ) exit( 'No direct script access allowed' );
– Add following code to Functions.php file of your child theme
require( 'class-form-generator.php' );
class-form-generator.php file is the file you are going to need to modify.
Best regards,
YigitJune 5, 2019 at 11:00 am #1107473you can reach it via child-theme functions.php.
i use it in combination with exclude dates.
If so these have to be before min-date / max-date setting:be carefull – do not exclude the dates with 01 for January etc – just 1
function exclude_datepicker_dates() { ?> <script type="text/javascript"> var unavailableDates = ["2019/1/15" , "2019/12/25"]; function unavailable(date) { ymd = date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate(); if (jQuery.inArray(ymd, unavailableDates) == -1) { return [true, ""]; } else { return [false, "", "Unavailable"]; } } </script> <?php } add_action('wp_footer', 'exclude_datepicker_dates', 10); function my_datepicker_defaults() { ?> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery.datepicker.setDefaults({ beforeShowDay: unavailable, minDate: new Date('2018/12/01'), maxDate: new Date('2019/12/31') }); }); </script> <?php } add_action('wp_footer', 'my_datepicker_defaults', 20);
June 5, 2019 at 11:02 am #1107474if you don’t want to exclude dates this will be enough:
function my_datepicker_defaults() { ?> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery.datepicker.setDefaults({ minDate: new Date('2018/12/01'), maxDate: new Date('2019/12/31') }); }); </script> <?php } add_action('wp_footer', 'my_datepicker_defaults', 20);
you can have relative dates by:
minDate: 0, maxDate: "+12m"
means from today til +12month
June 5, 2019 at 11:19 am #1107480by the way if you like to show datepicker without weekends:
place this to quick css:.ui-datepicker-week-end { display:none }
June 5, 2019 at 12:24 pm #1107494June 5, 2019 at 10:50 pm #1107759and
Is it possible to choose a span of dates when using the date picker in a contact form as opposed to just choosing one day? For instance booking a rental between a span of days instead a single day. Let me know when you get a minute. Thanks!
just place two datepicker fields beside each other one is the from the other to field
Sad : the topic is closed.
i tried to have a from to datepicker – and i want to have the value of the from field is the minDate of the to field.
I got this working – but it destroyes the styling of the datepicker – i don’t know why ?
(if the inputfields are in that position 6 and 7)function my_datepicker_defaults() { ?> <script type="text/javascript"> (function($) { $(document).ready(function(){ $('#avia_6_1').datepicker({onSelect: function(selectedDate) { $('#avia_7_1').datepicker('option', 'minDate', selectedDate); setTimeout(function() { $('#avia_7_1').focus(); }, 0); }}); $('#avia_7_1').datepicker({onSelect: function(selectedDate) { $('#avia_6_1').datepicker('option', 'maxDate', selectedDate); }}); }); })(jQuery); </script> <?php } add_action('wp_footer', 'my_datepicker_defaults', 10);
June 6, 2019 at 4:14 pm #1107984Thanks all and genius Guenni! Not sure why I didn’t think of that! ;)
Appreciate the code as well all. Thank you!
-
AuthorPosts
- The topic ‘Date picker in contact form – Date span instead of single date’ is closed to new replies.