Gulshan Gulshan - 19 days ago 5
Javascript Question

jQuery datepicker not working properly after append

I am appending row to table add new field but datepicker not working properly.May be its coz of multiple datepicker.i just need datepicker started from current date and next will be start from same date selected on first one.

var mydate = new Date();
jQuery(document).on('focus', ".datefrom", function () {
jQuery(this).datepicker({
format: 'dd-mm-yy',
minDate: new Date()
}).on('dateSelected', function (e, date)
{
mydate = date;
});
});
jQuery(document).on('focus', ".datetill", function () {
jQuery(this).datepicker({
format: 'dd-mm-yy',
minDate: mydate
});
});


Thanks in advance.

Here the snapshot:1

fiddle link https://jsfiddle.net/3oyxc97g/16/

Answer

try

var mydate=new Date();  
jQuery(document).on('focus',".datefrom", function(){ 
jQuery(this).datepicker({ 
      format : 'dd-mm-yyyy',
      autoclose :  true,
      todayHighlight : true,
      startDate : new Date()
}).on('changeDate', function(ev)
{
  mydate=jQuery('.datefrom').val();
});
});
......