Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery datepicker automatically append second field with first field input
    text
    copied!<p>I am using to datepicker fields, one for a Start date and one for an End date. I have got everything almost working as I require however I am struggling to get the End date field to update automatically when the start date field is selected if I don't have a default date. It work's fine if I have a default date in place but I need it to be blank in this case. I have setup the code on jsFiddle and would be extremely grateful if someone could point out how I can achieve this result.</p> <p><a href="http://jsfiddle.net/clj83/7TvKr/" rel="nofollow">http://jsfiddle.net/clj83/7TvKr/</a></p> <p>Here is the code below which is almost working.</p> <pre><code>$(function(){ var dates = $('#cntnt01cd_fax, #cntnt01cd_telephone').datepicker({ dateFormat: 'yy/mm/dd', changeMonth: false, changeYear: false, numberOfMonths: 3, showOtherMonths: true, selectOtherMonths: true, onSelect: function(selectedDate) { var option = this.id == 'cntnt01cd_fax' ? 'minDate' : 'maxDate'; var instance = $(this).data('datepicker'); var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings); dates.not(this).datepicker('option', option, date); } }); }); &lt;div class="form_title"&gt; Start Date &lt;/div&gt; &lt;div class="datepicker"&gt; &lt;input type="text" class="cntnt01cd_fax" name="cntnt01cd_fax" id="cntnt01cd_fax" value="" size="30" maxlength="255" /&gt; &lt;/div&gt; &lt;div class="form_title"&gt; End Date &lt;/div&gt; &lt;div class="datepicker"&gt; &lt;input type="text" class="cntnt01cd_telephone" name="cntnt01cd_telephone" id="cntnt01cd_telephone" value="" size="30" maxlength="255" /&gt; &lt;/div&gt; </code></pre> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload