Launch jQuery .datepicker from Another JS Function <p>I need to launch .datepicker only if the text entered into a field does not meet a set of criteria. But, I can not figure out how to launch .datepicker other than directly from a field getting focus or a button being presses.</p> <p>What I'm trying to do...</p> <p>The HTML</p> <pre><code>&lt;input type="text" id="userDate" name="userDate" style="width: 100px;" onblur="checkDate(this.id);" /&gt; </code></pre> <p>The JS</p> <pre><code>function checkDate(theId) { var enteredValue = document.getElementById(theId).value; var checkedValue = evaluateValue(enteredValue); // this checks to see if the text meets the criteria if (checkedValue == null) { // this is where I want to call the .datepicker to have the calendar show up $("#userDate").datepicker(); } else { document.getElementById(theId).value = checkedValue; } } </code></pre> <p>I know, this would be easier if the calendar just came up when the text field gets focus. But, this is not the way the client wants it to work. They want to accept user input as long as it falls into their desired formats. If not, then they want the calendar and a default, forced format.</p> <p>Thanks.</p>