JavaScript code normally goes in the theme's head section (header.php sometimes.) You will only need it on pages with your form though. In that case, you can save this jQuery to a file (call it date_restriction.js):
[js]
jQuery("#datepicker").datepicker({
beforeShowDay: function(date) {
var day = date.getDay();
return [(day != 1 && day != 2)];
}
});
(Change the $ to jQuery though, since $ won't work straight away in WordPress.)
Then include that file only when the specific form is called using the gform_enqueue_scripts hook:
[php]
// change the 11 here to your form ID
add_action('gform_enqueue_scripts_11', 'enqueue_date_restriction', 10, 2);
function enqueue_date_restriction($form, $is_ajax) {
// the script to restrict the dates is stored in the child theme /js/ subdirectory, and depends on jQuery
wp_enqueue_script('date_restriction', get_stylesheet_directory_uri() . '/js/date_restriction.js', array('jquery'));
}
Posted 12 years ago on Monday October 29, 2012 |
Permalink