title: JavaScript validation: regex to validate numbers with comma
body: <p>How do I use JavaScript regex to validate numbers like this?</p>
  
  <ol>
  <li>1,000</li>
  <li>1,000.00</li>
  <li>1000.00</li>
  <li>1000</li>
  </ol>
  
  <p>I tried this (the string used should not match):</p>
  
  <pre><code>test('2342342342sdfsdfsdf');
  
  function test(t)
  {
      alert(/\d{1,3}(,\d{3})*(\.\d\d)?|\.\d\d/.test(t));
  }
  </code></pre>
  
  <p>but still gives me true.</p>