Basic Year Picker For Text Input - YearPicker.js

Basic Year Picker For Text Input - YearPicker.js

YearPicker.js is a lightweight yet configurable year picker for jQuery that makes it easy to select a year from a popup similar to the date picker.

1. Add jQuery library together with the yearpicker.css and yearpicker.js to the page.

<link rel="stylesheet" href="yearpicker.css">
<script src="" 
<script src="yearpicker.js" async></script>

2. Add the class 'yearpicker' to the text field and we're done.

<input type="text" class="yearpicker" value="">

3. You can also apply the plugin to any text field you prefer.


4. All default options to customize the year picker.

  // Auto Hide
  autoHide: true,
  // Initial Year
  year: null,
  // Start Year
  startYear: null,
  // End Year
  endYear: null,
  // Element tag
  itemTag: 'li',
  // Default CSS classes
  selectedClass: 'selected',
  disabledClass: 'disabled',
  hideClass: 'hide',
  highlightedClass: 'highlighted',
  // Custom template
  template: `<div class="yearpicker-container">
              <div class="yearpicker-header">
                  <div class="yearpicker-prev" data-view="yearpicker-prev">&lsaquo;</div>
                  <div class="yearpicker-current" data-view="yearpicker-current">SelectedYear</div>
                  <div class="yearpicker-next" data-view="yearpicker-next">&rsaquo;</div>
              <div class="yearpicker-body">
                  <ul class="yearpicker-year" data-view="years">

5. Event handlers available.

  show: null,
  hide: null,
  pick: null

This awesome jQuery plugin is developed by saravanajd. For more Advanced Usages, please check the demo page or visit the official website.

  • Publication date: 12.09.2018
  • Source