any user
any user

Reputation: 155

I want to set the 2nd date picker value regarding first value in jquery UI date picker

if have two date picker 1 for checkin date and other for checkout i want if i select 28-06-2012 in checkin it autmatic disable dates befor 29-06-2012 in checkout date picker Here's the code

$(document).ready(function () {
    function getDateYymmdd(value) {
        if (value == null)
            return null;
        return $.datepicker.parseDate("yy-mm-dd", value);
    }

    $('.date').datepicker({ minDate: 1, dateFormat: "dd-mm-yy" });

    $('.date').each(function () {
        var minDdate = getDateYymmdd($(this).data(""));
        var maxDate = getDateYymmdd($(this).data("val-rangedate-max"));
        $(this).datepicker({

            maxDate: maxDate
        });
    });
    });

Upvotes: 0

Views: 252

Answers (3)

Alok Jha
Alok Jha

Reputation: 572

You are using bootstrap date picket, There is some Default function defines,

I have Something Like this: May This helps you also

jQuery(".dateone").datepicker({
         dateFormat:"yy-mm-dd",
         changeMonth: true,
         changeYear: true,
         minDate: 1,
     });

     jQuery(".datetwo").datepicker({
         dateFormat:"yy-mm-dd",
         changeMonth: true,
         changeYear: true,
         minDate: new Date($('.dateone').val()),
        });

Upvotes: 1

Hardik Raval
Hardik Raval

Reputation: 1940

Use "Jquery Ui Date picker ", DatePicker with Date Range Demo

Upvotes: 2

Ankur Verma
Ankur Verma

Reputation: 5933

$( "#frmDateStatusLog").datepicker({
    onSelect: function(dateText, inst){
          $("#toDateStatusLog").datepicker("option","minDate",$("#frmDateStatusLog").datepicker("getDate"));
    }
  });
  $( "#toDateStatusLog").datepicker({
    minDate: $("#frmDateStatusLog").datepicker("getDate")
  });

Demo

Upvotes: 0

Related Questions