Daniel Robinson
Daniel Robinson

Reputation: 653

Date Picker copy field value to another field

Using date picker if the users fills out the start date field how to I make the end date field copy that same value?

$('#sdate').datepicker({
 dateFormat: 'dd/mm/yy',
 changeMonth: true,
 changeYear: true ,
 firstDay: 1,
  onSelect : function(){
     document.getElementById('edate').value = $.datepicker.formatDate('dd/mm/yy', '#sdate');  
}
});

$('#edate').datepicker({
 dateFormat: 'dd/mm/yy',
 changeMonth: true,
 changeYear: true ,
 firstDay: 1
});

Upvotes: 1

Views: 2793

Answers (1)

j08691
j08691

Reputation: 207913

Change your onSelect function to:

onSelect: function () {
    $('#edate').val(this.value);
}

jsFiddle example

Upvotes: 4

Related Questions