25 October 2012

This snippet shows how to use jQuery datepicker in Drupal. Drupal already includes jQuery and jQuery UI in its core. So you just have to make sure it's loaded and then you can use it in your scripts.

Source code viewer
  1. drupal_add_library('system', 'ui.datepicker');
  2.  
  3. drupal_add_js('(function($){$().ready(function(){
  4. $("SELECTOR").datepicker({
  5. firstDay: 1,
  6. dateFormat:"dd.mm.yy"
  7. });
  8. });})(jQuery);', 'inline');
Programming Language: PHP