title: Convert input type text into date format
body: <p>I have one input type text:</p>
  
  <pre><code> &lt;input type="text" id="policyholder-dob" name="policyholder-dob" /&gt;
  </code></pre>
  
  <p>I want to type number in this field in mm/dd/yyyy format:
  like 01/01/2014
  This is my js code but its not working, what mistake have I made?</p>
  
  <pre><code>function dateFormatter(date) {
      var formattedDate = date.getDate() 
          + '/' + (date.getMonth() + 1) + '/' + date.getFullYear();
      return formattedDate;
  }
  
  var nextduedate = $("#policyholder-dob").val();
  
  var dateFormatDate = nextduedate.slice(0, 2);
  var dateFormatMonth = nextduedate.slice(2, 4);
  var dateFormatYear = nextduedate.slice(4, 8);
  var totalFormat = dateFormatMonth + '/' + dateFormatDate + '/' + dateFormatYear;
  var againNewDate = new Date(totalFormat);
  againNewDate.setDate(againNewDate.getDate() + 1);
  var todaydate = dateFormatter(againNewDate);
  
  $("#policyholder-dob").prop("value", todaydate);
  </code></pre>
  
  <p>Any help will be really appreciated.</p>