I've seen a lot of solutions on this thread about my issue but none of them works. I basically am using datepicker from jquery and below is this code

It works fine but i can't seem to set the end date not able to select less than the start date. For example, start date is 7th april so end date should not be allowed to choose any date before 7th.

Is there any way i could implement this with my current way of doing?

$(function() {
      $(".txtEndDate").datepicker({
        minDate: new Date(),
        changeMonth: true,
        changeYear: true,
        showOn: 'button',
        buttonImage: '../../../images/calendar.png',
        buttonImageOnly: true,
        title: 'Click to open calendar',
        alt: 'Click to open calendar'
      });

      $(function() {

        $(".txtStartDate").datepicker({
          minDate: new Date(),
          changeMonth: true,
          changeYear: true,
          showOn: 'button',
          buttonImage: '../../../images/calendar.png',
          buttonImageOnly: true,

          title: 'Click to open calendar',
          alt: 'Click to open calendar',

          onSelect: function(selected) {
            var start = $(this).datepicker("getDate");
            start.setDate(start.getDate() + 7);
            $(".txtEndDate").datepicker("setDate", start);
          }
        });
      });

0 Answers