title: How to display number in input field's to currency format in bootstrap addon?
body: <p>I'm working on small web form where I need to display number in the text field's as currency format in bootstrap appended addon.</p>
  
  <p>I'm able to achieve for a single field using jQuery selectors (I'm new to Javascript world), I wanted to do the same thing for aroung 10 fields.</p>
  
  <p>I think there must be elegant solution rather than writing the same for every field.</p>
  
  <p>Kindly help me.</p>
  
  <p>My HTML Code:</p>
  
  <pre><code>&lt;div class="control-group"&gt;
      &lt;label class="control-label"&gt;Loan Amount 1&lt;/label&gt;
      &lt;div class="controls"&gt;
          &lt;div class="input-append"&gt;
              &lt;input class="span2" id="loanAmount1" type="text"&gt;
              &lt;span class="add-on" id="loanAmount1Cur"&gt;$&lt;/span&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="control-group"&gt;
      &lt;label class="control-label"&gt;Loan Amount 2&lt;/label&gt;
      &lt;div class="controls"&gt;
          &lt;div class="input-append"&gt;
              &lt;input class="span2" name="loanAmount2" type="text"&gt;
              &lt;span class="add-on" name="LoanAmount2Cur"&gt;$&lt;/span&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My JS Code:</p>
  
  <pre><code>$(document).ready(function () {
          $("#loanAmount1").on("keyup", null, function () {
              var input = $("#loanAmount1").val();
              var num = parseFloat(input).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,') + " $";
              $("#loanAmount1Cur").html(num);
          });
      });
  </code></pre>
  
  <p>My JSFiddle: <a href="http://jsfiddle.net/kiranm516/me52djL8/24/" rel="nofollow noreferrer">http://jsfiddle.net/kiranm516/me52djL8/24/</a></p>
  
  <p>I copied the above code from (thanks to them): <a href="https://stackoverflow.com/questions/1990512/add-comma-to-numbers-every-three-digits-using-jquery">Add comma to numbers every three digits</a></p>