Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've got most of it, but could not figure out how to set the <code>hourMin</code> and <code>minuteMin</code> after the widget had already been initialized. Given the following HTML:</p> <pre><code>&lt;label for="from"&gt;From&lt;/label&gt;&lt;input id="from" name="from" /&gt; &lt;label for="to"&gt;To&lt;/label&gt;&lt;input id="to" name="to" /&gt; </code></pre> <p>And this JS:</p> <pre><code>$("#from").datetimepicker(); $("#to").datetimepicker({ beforeShow: function(input, inst) { var $toDateInput = $("#to"); var fromDate = $("#from").datetimepicker("getDate"); var toDate = $toDateInput.datetimepicker("getDate"); var afterFromDate; if (fromDate) { if (!toDate || (toDate &lt;= fromDate)) { afterFromDate = new Date(fromDate.toUTCString()); afterFromDate.setDate(afterFromDate.getDate() + 1); $toDateInput.datetimepicker("setDate", afterFromDate); } $toDateInput.datetimepicker("option", "minDate", fromDate); } } }); </code></pre> <p>See it here: <a href="http://jsfiddle.net/RWjtL/3/" rel="nofollow">http://jsfiddle.net/RWjtL/3/</a></p> <p>Most of your criteria are met, but there are a few things that are off:</p> <ul> <li>When you set the 'To' field blank, the 'From' datepicker's min date is not removed. I tried setting the <code>minDate</code> option to <code>null</code> and <code>""</code> and got weird behavior. <a href="https://github.com/trentrichardson/jQuery-Timepicker-Addon/issues#issue/56" rel="nofollow">Here's a documented issue that could be related</a>.</li> <li>The <code>beforeShow</code> method is called multiple times. I think this is because of the call to <code>setDate</code> inside the handler, but can't be sure.</li> <li>As stated above, I could not manage to set <code>hourMin</code> and <code>minuteMin</code> after the fact, and setting the <code>minDate</code> doesn't seem to respect the time part of the date.</li> </ul> <p>The author's <a href="https://github.com/trentrichardson/jQuery-Timepicker-Addon/issues" rel="nofollow">GitHub page</a> has a list of issues, some of which seem related to the issues I ran into. Hope that gets you started at least.</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