Set value of the textbox equal to the first activated date in datepicker

Set value of the textbox equal to the first activated date in datepicker

Help please,

my code is working, and it is activating only the day of week that i want, but by default the textbox has no value, i want the value of the textbox to be equal to the first date activated in my datepicker,

My code is:

<input type=text name='dtpick' id='datepicker'>
<script> var j = 3; $(function() { $('#datepicker').datepicker({ minDate: 0, beforeShowDay: function(date) { var weekDay = parseInt(j, 10); if (weekDay === date.getDay()) { return [true, '', '']; } return [false, '', '']; } }); // Getter var minDate = $( '#datepicker' ).datepicker( "option", "minDate" ); $( '#datepicker' ).datepicker( "option", "dateFormat", "yy-mm-dd" ); }); </script>


As u can see in this picture, wednesday is the only day activated, i want the first day activated (5-april-2017) in this case to be the value of the textbox: