Currency Formatting in JavaScript
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-money-in-javascript">How can I format numbers as money in JavaScript?</a>  </p>
</blockquote>



<p>I have a form with come simple JavaScript to perform an instant calculation. My problem is that I'm struggling to format it so that it displays correctly with commas and 2 decimal places.</p>

<p>Any help would be very much appreciated. Thank you.</p>

<pre><code>    &lt;p&gt;
    &lt;label&gt;My Daily Rate is:&lt;/label&gt;&lt;br /&gt;
&lt;input class="poundsBox" name="shares" id="shares" type="text" /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Your Gross Contract Take Home:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="result"&gt;&amp;pound; &lt;span id="result"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
The above illustration is provided for guidance only. Please complete the request form below for a detailed personal illustration.

&lt;script type="text/javascript"&gt;
$("#shares").keyup(function() {
   var val = parseFloat($(this).val());
   // If val is a good float, multiply by 260, else show an error
   val = (val ? val * 260 * 0.88 : "Invalid number");
   $("#result").text(val);
})
&lt;/script&gt;
</code></pre>
