PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Preset Datepicker to show a specific month

  1. I would like the datepickers on my form to open up automatically for October of this year instead of the current month, but I don't want to preselect a specific date.

    I am OK with doing this via jQuery if necessary, just need some direction, thanks.

    Posted 10 years ago on Tuesday July 2, 2013 | Permalink
  2. David Peralty

    Here is the datepicker that Gravity Forms uses - http://jqueryui.com/datepicker/ they have tutorials on that page on how to change what it shown when it opens. You'll want to look at their restrict date range, specifically the ability to set the beginning date as a specific date.

    Posted 10 years ago on Tuesday July 2, 2013 | Permalink
  3. So would I then be able to target the existing datepickers called by GravityForms and override the default settings?

    If you have a code example of this (even if it's to set different settings) I would really value seeing that, as in my experience getting the format right is usually the hardest part of writing jQuery.

    Posted 10 years ago on Tuesday July 2, 2013 | Permalink
  4. Richard Vav
    Administrator

    Something like this should work

    <script>
    jQuery(document).ready(function($){
    $( ".datepicker" ).datepicker({ minDate: "+3M" });
    });
    </script>

    You can find more about the various settings in the datepicker api documentation

    Edit: Thinking about it if October is going to be fixed you could also use default date like so

    $( ".datepicker" ).datepicker({ defaultDate: '10/1/2013' });
    Posted 10 years ago on Tuesday July 2, 2013 | Permalink

This topic has been resolved and has been closed to new replies.