Posts

Showing posts with the label jQuery

Add jQuery Date picker with month and year selection and a fix starting date

Image
  Today, I have learned how to add a jQuery date picker in Drupal 9 theme. I am going to share the steps and codes here.  Steps:  1. Add jquery library to your drupal 9 theme 2. Create a jquery file for  jQuery date picker 3. Apply custom css code to customized your needs. 4. Attach library to theme file 5. Add the date picker to bootstrap 5 form Dependencies:  jQuery jQuery Date Picker JavaScript Bootstrap 5 Drupal 9 Step 1:  Attach files to the theme's library for Drupal: Open your themes libraries.yml file and put the following code:  datepicker :   version : VERSION   css :       theme :         assets/custom/datepicker/datepicker.css : {}   js :       //code.jquery.com/jquery-3.6.0.js : { type : external }       //code.jquery.com/ui/1.13.1/jquery-ui.js : { type : external }       assets/custom/datepicker/datepicker.js : {} Step 2:  Create a JavaScript file as linked in libraries: ( assets/custom/datepicker/datepicker.js) and put the following jQuery codes: $ ( function () {