title: JQuery DatePicker set default date on page load
body: <p>I am using 2 JQueryUI Date Pickers for an application where I am using ajax to post the dates to a back end MySQL database.  The first datepicker is used to post the initial date.  The second datepicker is used to post the modified date.  </p>
  
  <p>I am having an issue when a user does not select a date from the date picker, in either instance.  This is due to the onSelect function being used to retrieve the date value which is passed to ajax to post in the MySQL db.  </p>
  
  <p>I believe I need to define default date values for both datepickers when the page loads, so that if the user has not selected a date it will not be undefined when it gets passed to the AJAX to post.</p>
  
  <p>What is the best way to do this?  </p>
  
  <pre><code>&lt;script&gt;
  $(function() {
  $( ".datepicker" ).datepicker({
          inline: true,
          //nextText: '&amp;rarr;',
          //prevText: '&amp;larr;',
          showOtherMonths: true,
          dateFormat: 'yy-mm-dd',
          dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
          //showOn: "button",
          //buttonImage: "img/calendar-blue.png",
          //buttonImageOnly: true,
          onSelect: function(dateText, inst) {
              reservationDate = $(".datepicker[name=datepicker1]").val();
              modifyDate = $(".datepicker[name=datepicker2]").val();
              }
      });
  });
  &lt;/script&gt;
  
  &lt;input type="text" class='datepicker' name="datepicker1" /&gt;
  &lt;input type="text" class='datepicker' name="datepicker2" /&gt;
  </code></pre>