Search the site :

set your maximum time range of selection for DateRangePicker.js

I wanted to create a date range picker where we i can set maximum dateselection range of 3 months so i edited the Daterangepicker.js :

let us first look at the date range picker you can add the beautiful date range

selector by adding this code

HTML:

input type="text"

jQuery:

$('input').daterangepicker();

now you have to edit daterangepicker.js :

i have setted the max date selection range as 3 months you can make it

to any of your choice here is my code : http://jsfiddle.net/W2YLr/

what i have edited :

i edited the datepicker option section as :


if(rp.find('li.ui-state-active').is('.ui-daterangepicker-allDatesBefore'))
 {
  var edtemp = new Date(new Date(ed).setMonth(ed.getMonth()-3));    
  rangeA=fDate(edtemp);   
 startingDate=edtemp;
  endingDate=ed;                    
  }

you can find some -3 and +3 codes inside the date picker you can change this values with

how many months you need it .

i also edited the hideRP() function so that now you can get the startdate and enddate

through jquery call of the event onClose


$('input').daterangepicker()

{

onClose:function(startdate,enddate)

{

alert("start date:"+startdate+"end date:"+enddate);

}

}

Comments powered by Disqus
Contents © 2014 Kaushik Gandhi - Designed and built using Nikola, and hosted on github
Creative Commons License BY-NC-SA