Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to constrain min and max dates for jQuery-ui datepicker based on another date
    primarykey
    data
    text
    <p>I would like to know how can we set the check-out date between the check-in date. Like if we select the month of June (when current month is February) and the 15th day. So it gives the authority to select the day between 30 days(30 limit). So the end date would be: 15 July. Here we have a code: </p> <pre><code>&lt;link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/black-tie/jquery-ui.css" media="screen" /&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"&gt;&lt;/script&gt; &lt;style type="text/css"&gt; body{ font: 60.0% "Trebuchet MS", sans-serif; margin: 50px; } &lt;/style&gt; &lt;script type="text/javascript"&gt; $(function() { $('#from').datepicker({ numberOfMonths: 2, firstDay: 1, dateFormat: 'DD dd-mm-yy', minDate: '0', maxDate: '+2Y', onSelect: function(dateStr) { var min = $(this).datepicker('getDate'); $('#to').datepicker('option', 'minDate', min || '0'); datepicked(); } }); $('#to').datepicker({ numberOfMonths: 2, firstDay: 1, dateFormat: 'DD dd-mm-yy', minDate: '0', maxDate: '+2Y', onSelect: function(dateStr) { var max = $(this).datepicker('getDate'); $('#from').datepicker('option', 'maxDate', max || '+2Y'); datepicked(); } }); }); var datepicked = function() { var from = $('#from'); var to = $('#to'); var nights = $('#nights'); var fromDate = from.datepicker('getDate') var toDate = to.datepicker('getDate') if (toDate &amp;&amp; fromDate) { var difference = 0; var oneDay = 1000 * 60 * 60 * 24; var difference = Math.ceil((toDate.getTime() - fromDate.getTime()) / oneDay); nights.val(difference); } } &lt;/script&gt; &lt;input type="text" id="from" name="from" size="28" style="width:194px; /*Tag Style*/" value="" &gt; &lt;input type="text" id="to" name="to" size="28" style="width:194px; /*Tag Style*/" value="" &gt; &lt;input type="text" id="nights" name="nights" size="4" style="width:50px; /*Tag Style*/" value="" readonly="readonly"&gt; </code></pre> <p>Our Main motive is to make this code, for check-in, check out and nights. In which check-in dates can be any month in 2012-2013, and Check - out date will only be the check-in date after 30 days, and the total nights will be 30 nights only. </p>
    singulars
    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