title: Prevent negative value after jquery calculation
body: <p>when I calculate the difference between the start date and end date - it is possible for the end date to be entered as being "before" the start date - therefore allowing a negative calculation value in "totaldays".   )I have used the "min" to ensure that the start date cannot be "before today".   )</p>
  
  <p>also, is it possible for "total_days" result (result of calculation) to be hidden until the calculation is complete - ie so that you do not see the long decimal value: such as -15489.916666666666</p>
  
  <p>I have tried to complete this on my own, but have very very limited javascript / jquery knowledge. I would value any response. :-)  Thank you</p>
  
  <pre><code>&lt;title&gt;Conference Form&lt;/title&gt;
  
  
  
  &lt;script type="text/javascript" src="js/jquery.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="js/jqueryui.js"&gt;&lt;/script&gt;
  &lt;link href="style.css" rel="stylesheet" type="text/css"/&gt;
  &lt;link href="css/jqueryui.css" rel="stylesheet" type="text/css" /&gt;
  
  &lt;body&gt;
  
  &lt;div id="wrapper"&gt;
  &lt;div id="header"&gt;&lt;/div&gt;
  
  &lt;table width="705" border="1" align="left" cellpadding="1"&gt;
    &lt;form action="" method="get" name="myform"&gt;
  
    &lt;tr&gt;
      &lt;td width="151"&gt;&lt;label&gt;Company Name&lt;/label&gt;&lt;/td&gt;
      &lt;td width="158"&gt;&lt;input type="text" name="companyname" id="companyname" /&gt;&lt;/td&gt;
      &lt;td width="155"&gt;Enquiry Date&lt;/td&gt;
      &lt;td width="213"&gt;&lt;input type="text" name="enquiry_date" id="enquiry_date" class="datepicker" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Conference Date In&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="conference_date_in" id="conference_date_in" class="datepicker" /&gt;&lt;/td&gt;
      &lt;td&gt;Conference Date Out&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="conference_date_out" id="conference_date_out" class="datepicker" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Number of Delegates&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="no_of_delegates" id="no_of_delegates" /&gt;&lt;/td&gt;
      &lt;td&gt;Total Days&lt;/td&gt;
    &lt;td&gt;&lt;input type="text" name="total_days" id="total_days" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/form&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;script type="text/javascript"&gt;
  
  $(function() {
      $(".datepicker").datepicker({ minDate: -0, maxDate: "+100M +10D",dateFormat: 'dd-mm-yy'})
      ({
          changeMonth: true,
          changeYear: true,
      });
          });
  
  
  var enquiry_date = $.datepicker.formatDate('dd-mm-yy', new Date());
  document.getElementById('enquiry_date').value = enquiry_date;
  
  var calcDate = function() {
      var start = $('#conference_date_in').datepicker('getDate');
      var end = $('#conference_date_out').datepicker('getDate');
      var days = (end - start) / 1000 / 60 / 60 / 24;
  
      document.getElementById('total_days').value = days;
  }
  
  
  $('#conference_date_out').change(calcDate);
  $('#conference_date_in').change(calcDate);
  &lt;/script&gt;
  </code></pre>