title: Adding leading zero with javascript?
body: <p>I need to add a leading zero to the month on the "Next day" text box for all 9 months and leave it off on 10,11,12. I haven't a clue how to achieve that.</p>
  
  <p>Help!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function(){
  
   var currentDate = new Date()
      var day = currentDate.getDate()
      if(day &lt;= 9)
      day = '0'+day;
      var month = currentDate.getMonth() + 1
      if(month &lt;= 9)
      month = '0'+month;
      var year = currentDate.getFullYear()
      document.getElementById("element_183").value =("" + month + "/" + day + "/" + year + "")
  
      function DateFromString(str){ 
          str = str.split(/\D+/);
          str = new Date(str[2],str[0]-1,(parseInt(str[1])+90));
          return MMDDYYYY(str);
      }
      
      function MMDDYYYY(str) {
          var ndateArr = str.toString().split(' ');
          var Months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec';
          return (parseInt(Months.indexOf(ndateArr[+1])/4)+1)+'/'+ndateArr[2]+'/'+ndateArr[3];
      }
  
      function Add90Days() {
          var date = $('#element_183').val();
          var ndate = DateFromString(date);
          return ndate;
      }
  
      $('#element_183').ready(function(){
          $('#element_184').val(Add90Days());
      });
  
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;
  Enter date:&lt;input type="text" id="element_183" readonly&gt;
  Next date:&lt;input type="text" id="element_184" readonly&gt;</code></pre>
  </div>
  </div>
  </p>