Advertisement
eventsmanager

Date Picker Specific Date Ranges

Jun 8th, 2019
789
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <?php
  2. /*
  3. This snippet changes a datepicker option values for a specific datepicker field, edit the .input-field-dates to your specific form class names.
  4.  
  5. For installation instructions, please visit http://wp-events-plugin.com/tutorials/how-to-safely-add-php-code-to-wordpress/
  6. */
  7. function my_em_datepicker_vals(){
  8.     ?>
  9.     <script type="text/javascript">
  10.         jQuery(document).ready(function(){
  11.             var date = new Date();
  12.             //in this example, we're going back 19 years for a specific field
  13.             date.setFullYear( date.getFullYear() - 19 );
  14.             //.input-field-dates is a class assigned to the encapsulating wrapper tag around the date fields, check your source code for your specific class name
  15.             jQuery('.input-field-dates .em-date-start').datepicker('option', 'minDate', date);
  16.         });
  17.     </script>
  18.     <?php
  19. }
  20. add_action('wp_head','my_em_datepicker_vals',1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement