Properly filtering an input field in Angular
<p>I found this directive for filtering a field for currency, so a user just needs to type and the decimal is implied.</p>

<p>It works well, except that a user is able to put in a letter if they press a letter twice. I don't want them to be able to put in a letter at all.</p>

<p>I tried changing the <code>type="number"</code> but then it would only allow 5 digits before disappearing inexplicably. You can see this at this plunker:</p>

<p><a href="http://plnkr.co/edit/Y1olj7Cdz7XKqRmE7BFb?p=preview" rel="nofollow">http://plnkr.co/edit/Y1olj7Cdz7XKqRmE7BFb?p=preview</a></p>

<p>So either I need to change something (the regex?) in this line: </p>

<pre><code>var plainNumber = viewValue.replace(/[^\d|\-+]/g, '');
</code></pre>

<p>or somehow fix the type="number" to keep input past five digits. Anybody know what to do here?</p>