Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- wpgenie.org
- limit date picker so past dates cannot be selected, this JS code snippet should go to your child theme functions.php or customization plugin
- https://wpgenie.org/tutorials-category/code-snippets-and-template-customizations-using-child-theme
- */
- function wpgenie_limit_past_dates_in_datepicker() {
- ?>
- <script>
- jQuery(document).ready(function($) {
- jQuery('.datetimepicker').datetimepicker(
- {defaultDate: "",
- dateFormat: "yy-mm-dd",
- numberOfMonths: 1,
- showButtonPanel: true,
- minDate: new Date(),
- showOn: "button",
- buttonImage: SA_Ajax.calendar_image,
- buttonImageOnly: true
- });
- });
- </script>
- <?php
- }
- add_action( 'admin_head', 'wpgenie_limit_past_dates_in_datepicker' ); // loads JS in wp-admin / backend, comment line if not required in backend
- add_action( 'wp_head', 'wpgenie_limit_past_dates_in_datepicker'); // loads JS in frontend, comment line if not required in frontend
Advertisement
Add Comment
Please, Sign In to add comment