title: Regular Expression for dollar amount in JavaScript
body: <p>I know this has been done a thousand times before but I'm having trouble with getting this right. I need to format the value of a text input for dollar amounts. No commas should be allowed. Only two decimal places should be allowed.
  Examples of what should be allowed:</p>
  
  <ul>
  <li>100</li>
  <li>100.10</li>
  <li>$100</li>
  <li>$100.25</li>
  </ul>
  
  <p>Below is my current incomplete regular expression. It currently allows multiple dollar signs to be included anywhere (not just at beginning), multiple decimal points to be included anywhere, and more than two decimal places which it shouldn't. </p>
  
  <p></p>
  
  <pre><code>&lt;head&gt;
  &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" language="Javascript"&gt;
      $(function(){
  
          jQuery('.dollarAmountOnly').keyup(function () {
              this.value = this.value.replace(/[^$0-9\.]/g, '');
          });
      });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;input type="text" class="dollarAmountOnly"/&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I would greatly appreciate help. Thanks!</p>