JQuery goes to past date with the Date range

JQuery goes to past date with the Date range

i'm using the date range with two textbox (fromDate,toDate), each one with icon trigger function . when i disable the "fromDate" the toDate can be goes to past dates ,i want to disable this and normally use like if no disabled textbox.

this is the jquery

  1. $(function () {     
  2. $("#fromDate").datepicker({
  3.          changeMonth: true,
  4.          changeYear: true,
  5.          numberOfMonths: 1,
  6.          showOn: "button",
  7.          buttonImage: "http://jqueryui.com/resources/demos/datepicker/images/calendar.gif",
  8.          buttonImageOnly: true,
  9.          dateFormat: "dd-mm-yy",
  10.          onClose: function (selectedDate) {
  11.              $("#toDate").datepicker("option", "minDate", selectedDate);
  12.          }
  13.      });

  14.      //check if disabled disable th datepiker icon also
  15.      var disabled = $('#fromDate').attr('disabled');
  16.      if (disabled == "disabled") {
  17.          $("#fromDate").datepicker('disable');
  18.          $("#toDate").datepicker("option", "minDate", $('#fromDate').val());
  19.      } else {
  20.          $("#fromDate").datepicker('enable');
  21.      }

  22.      $("#toDate").datepicker({
  23.          defaultDate: new Date(),
  24.          changeMonth: true,
  25.          changeYear: true,
  26.          numberOfMonths: 1,
  27.          showOn: "button",
  28.          buttonImage: "http://jqueryui.com/resources/demos/datepicker/images/calendar.gif",
  29.          buttonImageOnly: true,
  30.          dateFormat: "dd-mm-yy",
  31.          onClose: function (selectedDate) {
  32.              $("#fromDate").datepicker("option", "maxDate", selectedDate);
  33.          }
  34.      });
  35.  });


this is my html

  1. <input type="text" id="fromDate" name="fromDate" value="05-06-2013" disabled="disabled" />
  2. <input type="text" id="toDate" name="toDate" />

this is my code running with the issue link