Allocation of digits in the price list
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1068284/format-numbers-in-javascript">Format numbers in javascript</a><br>
  <a href="http://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript">How to print a number with commas as thousands separators in JavaScript</a>  </p>
</blockquote>



<p>I want to separate the zeros of the gap in the price list.</p>

<p>As example</p>

<p>current: 150000
wanted: <strong>150 000</strong></p>

<p>current: 2730000
wanted: <strong>2 730 000</strong></p>

<p>Using jQuery and all browsers (Chrome, Firefox, IE, Opera)</p>

<p>UPD I want to dynamically add spaces when entering numbers</p>

<pre><code>Step by step: user entered 10, in input 10
100 - 100
1000 - 1 000
10000 - 10 000
100000 - 100 000
1000000 - 1 000 000
</code></pre>

<p>UPD I used regex
<code>val.replace(/(\S)(?=(\S\S\S)+(?!\S))/g, "$1 ");</code>
It's correct works in FF only</p>
