Advertisement
artemsemkin

Contact Form 7 Date Picker: init string

Mar 11th, 2021
791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function get_todate() {
  2.   var today = new Date();
  3.   var dd = today.getDate();
  4.   var mm = today.getMonth()+1; //January is 0!
  5.   var yyyy = today.getFullYear();
  6.   if(dd<10) {
  7.     dd = '0'+dd
  8.   }
  9.   if(mm<10) {
  10.     mm = '0'+mm
  11.   }
  12.   today = yyyy + '-' + mm + '-' + dd;
  13.   return today;
  14. }
  15.  
  16. function get_tomorrow() {
  17.   var tomorrow = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);
  18.   var dd = tomorrow.getDate()
  19.   var mm = tomorrow.getMonth() + 1
  20.   var yyyy = tomorrow.getFullYear()
  21.   if(dd<10) {
  22.     dd = '0'+dd
  23.   }
  24.   if(mm<10) {
  25.     mm = '0'+mm
  26.   }
  27.   tomorrow = yyyy + '-' + mm + '-' + dd;
  28.   return tomorrow;
  29. }
  30.  
  31. jQuery('.walcf7-datetimepicker').each(function(index, element) {
  32.   var todate = get_todate();
  33.   var tomorrow = get_tomorrow();
  34.   jQuery(this).datetimepicker({
  35.     dayOfWeekStart : 1,
  36.     yearStart: '1900',
  37.     lang:'en',
  38.     format:'Y-m-d H:i',
  39.     formatDate:'Y-m-d',
  40.     formatTime:'H:i',
  41.     defaultTime:'10:00',
  42.     //disabledDates:[todate],
  43.     startDate:tomorrow,
  44.  
  45.     onGenerate: function( ct, $input ){
  46.       $input.prop('readonly', true);
  47.       var $this = jQuery(this);
  48.       $this.find('.xdsoft_date').removeClass('xdsoft_disabled');
  49.       $this.find('.xdsoft_time').removeClass('xdsoft_disabled');
  50.     }                      
  51.   });
  52. });
  53.  
  54. jQuery('.walcf7-datepicker').each(function(index, element) {
  55.   var todate = get_todate();
  56.   var tomorrow = get_tomorrow();
  57.   jQuery(this).datetimepicker({
  58.     dayOfWeekStart : 1,
  59.     yearStart: '1900',
  60.     lang:'en',
  61.     timepicker:false,
  62.     format:'Y-m-d',
  63.     formatDate:'Y-m-d',
  64.     //disabledDates:[todate],
  65.     startDate:tomorrow,
  66.     onGenerate: function( ct, $input ){
  67.       $input.prop('readonly', true);
  68.       var $this = jQuery(this);
  69.       $this.find('.xdsoft_date').removeClass('xdsoft_disabled');
  70.       $this.find('.xdsoft_time').removeClass('xdsoft_disabled');
  71.     }                      
  72.   });
  73. });
  74.  
  75. jQuery('.walcf7-timepicker').each(function(index, element) {
  76.   jQuery(this).datetimepicker({
  77.     datepicker:false,
  78.     ignoreReadonly: true,
  79.     allowInputToggle: true,
  80.     format:'H:i',
  81.     defaultTime:'10:00',
  82.     step:15,
  83.     onGenerate: function( ct, $input ){
  84.       $input.prop('readonly', true);
  85.       var $this = jQuery(this);
  86.       $this.find('.xdsoft_date').removeClass('xdsoft_disabled');
  87.       $this.find('.xdsoft_time').removeClass('xdsoft_disabled');
  88.     }
  89.   });
  90. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement