Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #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!

    #1107254

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

    #1107457

    Hi,

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

    #1107473

    you 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);
    #1107474

    if 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

    #1107480

    by the way if you like to show datepicker without weekends:
    place this to quick css:

    .ui-datepicker-week-end {
    	    display:none
    }
    #1107494

    Hi,


    @Guenni007
    thanks for your help :)

    Best regards,
    Yigit

    #1107759

    and

    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);
    #1107984

    Thanks all and genius Guenni! Not sure why I didn’t think of that! ;)

    Appreciate the code as well all. Thank you!

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Date picker in contact form – Date span instead of single date’ is closed to new replies.