title: Currency input with Twitter Bootstrap (using jQuery)
body: <p>I'm using Twitter Bootstrap (v3) and I want to make a money input, where I can enter an amount of money with a fixed currency (currently €).</p>
  
  <p>The input type needs to be <code>type="number"</code> because of how I want the input to look on mobile devices (not a big QWERTY keyboard, just numbers), but I do want to allow multiple patterns.</p>
  
  <p>I think the way to go is with the .on("input", callback) method, but I'm not sure how to accomplish this.</p>
  
  <p>I have tried the following:</p>
  
  <pre><code>$(document).ready(function() {
      $("#amount").on("input", function() {
          // allow numbers, a comma or a dot
          $(this).val($(this).val().replace(/[^0-9,\.]+/, ''));
      });
  });
  </code></pre>
  
  <p>(for the HTML and CSS, see the jsfiddle link)</p>
  
  <p>But obviously that doesn't work, otherwise I wouldn't be posting here. Whenever you try to type something invalid, the whole string disappears.</p>
  
  <p><a href="http://jsfiddle.net/bjcayhzb/1/" rel="nofollow">http://jsfiddle.net/bjcayhzb/1/</a></p>
  
  <p>Explanation rather than (or alongside) a working example highly is appreciated.</p>