Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Datepicker onSelect is not working
    primarykey
    data
    text
    <p>I am using the <code>onSelect</code> event in order to set the minimum value of the <code>EndDate</code> equal to the value set as a <code>StartDate</code>. I have the same code in several pages but in one of them it does not work. If I select a value in the <code>StartDate</code>, datepicker does not show when I go in the <code>EndDate</code> field. The pages are loaded and handled with ajax.</p> <p>My Code is as follows:</p> <pre><code>$(document).ready(function() { $("#strStartDate").datepicker({ dateFormat: 'dd/mm/yy', constrainInput: true, firstDay: 1, hideIfNoPrevNext: true, onSelect: function(){ $("#strEndDate").datepicker( "option", "minDate", $("#strStartDate").val()); } }); $("#strEndDate").datepicker({ dateFormat: 'dd/mm/yy', constrainInput: true, firstDay: 1, hideIfNoPrevNext: true }); }); </code></pre> <p>Any help is much appreciated. Thank you in advance.</p> <p>Using the ideas behind your comments I manage to do almost the thing I want</p> <pre><code>$("#strStartDate").datepicker({ dateFormat: 'dd/mm/yy', constrainInput: true, firstDay: 1, hideIfNoPrevNext: true, }); $("#strEndDate").datepicker({ dateFormat: 'dd/mm/yy', constrainInput: true, firstDay: 1, hideIfNoPrevNext: true, beforeShow: function (input, inst) { inst.settings.minDate = $("#strStartDate").val(); } }); </code></pre> <p>The above code restricts user from putting an end date smaller than the start date however if there was already a value in end date, and you change the start date to a value bigger than the end date it should set the end date equal to the start date. This is what I was trying to do with the code below in my early code</p> <pre><code>onSelect: function(){ $("#strEndDate").datepicker( "option", "minDate", $("#strStartDate").val()); } </code></pre> <p>Any idea how to do this using the instance and not initialize again?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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