Title: Problem with custom minDate values
Last modified: August 21, 2016

---

# Problem with custom minDate values

 *  [Alex Stanhope](https://wordpress.org/support/users/247creative/)
 * (@247creative)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/problem-with-custom-mindate-values/)
 * Hi Relu,
 * I have been using the Contact Form 7 Datepicker plugin on a WP-based site, but
   seem to have run into something of an issue with the minDate value!
 * We’ve had to use some custom jQuery to modify how the date picker works, but 
   for some reason, it’s not working correctly, whereas it does behave itself if
   we use the native CF7 date function (however, as the dates need to be formatted
   in dd/mm/yy, the forms can’t be submitted using CF7 as they don’t pass its inbuilt
   mm-dd-yyyy requirements) – do you have any idea how we can get the script below
   to play ball with your date picker plug-in? There are actually two date pickers
   that need to use the following (each one is on a separate form).
 *     ```
       function daysInMonth(iMonth, iYear){
       return 32 - new Date(iYear, iMonth, 32).getDate();
       }
   
           var currentTime = new Date();
           var day = currentTime.getDate();
           var t = (day > 1) ? 3 : 2;
           var month = currentTime.getMonth() + t;
           var year = currentTime.getFullYear();
   
           if(month > 12){
               month = month - 12;
               year = year + 1;
           }
   
           jQuery('#freeze-start-date').datepicker({
                   dateFormat: 'dd/mm/yy',
                   minDate: "01/" + month + "/" + year,
                   onClose: function(dateText, inst) {
                       if(dateText != "") {
                           var how = jQuery("#menu-1451").val();
                           how = parseInt(how);
                           var end1 = dateText.split('/');
   
                           var begin = "01/" + end1[1] + "/"+end1[2];
                           var end3 = end1[2];
                           var end2 = end1[0];
                           if(end2 != "01") {
                               alert("Freeze can only start from 1st day of the month");
                           }
                           end2 = daysInMonth(end1[1]-1-1+how,end1[2]);
   
                           emonth = parseInt(end1[1],10) - 1 + how;
                           if(emonth > 12) {
                               emonth = emonth - 12;
                               end3 = parseInt(end3,10)+1;
                           }
                           if(emonth <= 9) emonth = "0"+emonth;
                           jQuery("#freeze-start-date").val(begin);
                           jQuery("#freeze-end-date").val(end2+"/"+emonth+"/"+end3);
                       }
                   }
           });
   
           jQuery('#cancel-date').datepicker({ 
   
                   dateFormat: 'dd/mm/yy',
                   minDate: "01/" + month + "/" + year,
                   onClose: function(dateText, inst) {
                       if(dateText != "") {
                           var end1 = dateText.split('/');
                           var begin = "01/" + end1[1] + "/"+end1[2];
                           if(end1[0] != "01")
                           {
                               alert("Cancellation is allowed only on the 1st day of the month");
                           }
                           jQuery('#cancel-date').val(begin);
                       }
                   }
           });
       ```
   
 * [http://wordpress.org/plugins/contact-form-7-datepicker/](http://wordpress.org/plugins/contact-form-7-datepicker/)

The topic ‘Problem with custom minDate values’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/contact-form-7-datepicker.svg)
 * [Contact Form 7 Datepicker](https://wordpress.org/plugins/contact-form-7-datepicker/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7-datepicker/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7-datepicker/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7-datepicker/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7-datepicker/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7-datepicker/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Alex Stanhope](https://wordpress.org/support/users/247creative/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/problem-with-custom-mindate-values/)
 * Status: not resolved