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.

Datepicker jQuery - modify function and styling

  1. Hi,

    Looked through support and wider online resources but hitting a wall and in need of some assistance.

    I have a WordPress site, with a Contact page.
    Using Gravity forms for the Contact form.
    I have two date pickers, essentially a 'start' and 'end'.
    I want selection of 1st to be reflected in the 2nd - in that the end datepicker can display no dates earlier than the start date.

    In a 'test' html page I have this working perfectly:
    http://dev.twentyfourten.com/clients/daleygolfholidays/test.html

    Code used is this:

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"  />
        <script type="text/javascript">
    	jQuery.noConflict();
       jQuery(document).ready(function($) {
        $("#txtFromDate").datepicker({
            minDate: 0,
            maxDate: "+365D",
            numberOfMonths: 2,
    		dateFormat: 'dd/mm/yy',
            onSelect: function(selected) {
              $("#txtToDate").datepicker("option","minDate", selected)
            }
        });
        $("#txtToDate").datepicker({
            minDate: "+7D",
            maxDate:"+365D",
            numberOfMonths: 2,
    		dateFormat: 'dd/mm/yy',
            onSelect: function(selected) {
               $("#txtFromDate").datepicker("option","maxDate", selected)
            }
        });
    });
    
    </script>

    However, when I try and work this code in to my WordPress Contact page I don't get the same results:
    http://www.daleygolfholidays.co.uk/contact-us/

    Here I am using the following code up in the wp-head section:

    <script type="text/javascript">
    	jQuery.noConflict();
       jQuery(document).ready(function($) {
        $("input_1_5").datepicker({
            minDate: 0,
            maxDate: "+365D",
            numberOfMonths: 2,
    		dateFormat: 'dd/mm/yy',
            onSelect: function(selected) {
              $("input_1_6").datepicker("option","minDate", selected)
            }
        });
        $("input_1_6").datepicker({
            minDate: "+7D",
            maxDate:"+365D",
            numberOfMonths: 2,
    		dateFormat: 'dd/mm/yy',
            onSelect: function(selected) {
               $("input_1_5").datepicker("option","maxDate", selected)
            }
        });
    });
    
    </script>

    * Datepicker IDs are changed from test version to Gravity form inputs

    And down in my footer after all other scripts I am using the following refs:

    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"  />

    As you can see when viewing the page and using the datepickers, neither the function nor styling is as seen in the test page.

    I've tried moving the script in the header down into the footer, the links in the footer up to being with the header script, no dice - the original Gravity form settings still seem to be 'in control'.

    Would appreciate some help!

    Cheers

    Posted 11 years ago on Thursday December 6, 2012 | Permalink
  2. 10 minutes later, I've looked back at form and realised I've missed the # off the input IDs. Apologies ... and let this be a lesson to everyone to take a break once in a while and look at your code with fresh eyes.

    Cheers

    Posted 11 years ago on Thursday December 6, 2012 | Permalink
  3. David Peralty

    I'm glad you were able to figure it out, and that's something we all must do sometimes. I can't tell you the number of times in working with PHP that I am left searching for the missing semi-colon that is right in front of my eyes.

    Posted 11 years ago on Thursday December 6, 2012 | Permalink