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.

Need Help Setting Date Limit (I have searched but still need help)

  1. aomisore
    Member

    I have searched and found some threads with some info. The only problem is most of it is over my head. The one item I found which works easily says to edit the ui.datepicker.js. This works for stopping the date picker from allowing dates before TODAY, but it does not stop someone from typing in the date manually.

    I have seen links that point me here:
    http://docs.jquery.com/UI/Datepicker#option-minDate

    But I really have no clue what to do. I am looking to have someone give me explicit instructions. IE, put "THIS" here and put "THAT" there.

    I want to stop visitors from putting in a past dates and todays date.

    Posted 11 years ago on Thursday November 29, 2012 | Permalink
  2. Do not edit the ui.datepicker.js as that will affect all uses of the datepicker, which might be undesirable, and also you would lose those changes when the plugin is updated.

    Posted 11 years ago on Saturday December 1, 2012 | Permalink
  3. Add this jQuery to your theme's header.php, before the call to wp_head(). Ideally,. this would be added conditionally, on the page where the form is going to be used, but let's start by just getting it to work:

    [js]
    <script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(function($) {
    	$( "#input_1_8" ).datepicker({
    	  minDate: '+1',
    	  gotoCurrent: true,
    	  prevText: '',
    	  showOn: 'both',
    	  buttonImage: '/wp-content/plugins/gravityforms/images/calendar.png',
    	  buttonImageOnly: true });
    	});
    </script>

    You will need to change '#input_1_8' to the actual ID of the field which is utilizing the datepicker now. After you do that, please post a link to the page on your site where the form is visible. Thank you.

    Reference:
    http://www.gravityhelp.com/documentation/page/Where_Do_I_Put_This_Code%3F

    Posted 11 years ago on Saturday December 1, 2012 | Permalink
  4. What should the code look like if I have several forms?

    Posted 11 years ago on Sunday December 2, 2012 | Permalink
  5. In line 4 above, the form ID and field ID are both present. That piece of information will need to change to work on multiple forms.

    I guess it depends on how many forms you have. With dozens of forms it would be a pain to manage. With three forms, you could just have three of these scripts and include the correct one in the page for each specific form. If the field ID is always the same, it will be a little easier.

    Posted 11 years ago on Sunday December 2, 2012 | Permalink