title: how to replace input numbers with commas after key presses
body: <p>I want to replace a number over 100 with commas. Like 1000 to 1,000 and 1000000 to 1,000,000 etc. in HTML. I have found the code on here to do so but it only works with predetermined numbers being passed. I don't want it to work for a predetermined number but for any number typed into the box. </p>
  
  <pre><code>&lt;label for="turnover"&gt;Estimated Monthly Card Turnover:&lt;/label&gt;&lt;br /&gt;
      &lt;span&gt;&amp;pound; &lt;/span&gt;&lt;input type="text" id="turnover" maxlength="11" 
      name="turnover" size="10" required&gt;*
      &lt;br /&gt;&lt;br /&gt;
  
  
  &lt;script type="text/javascript"&gt;
      $('#turnover').keydown(function(){
          var str = $(this).val();
          str = str.replace(/\D+/g, '');
          $(this).val(str.replace(/\B(?=(\d{3})+(?!\d))/g, ","));});
  
  
      &lt;/script&gt;
  </code></pre>