Luke Flournoy Luke Flournoy - 5 months ago 34
AngularJS Question

How to restrict an html input to positive decimal numbers up two decimals?

I am writing a angularjs app and am trying to restrict an html tag to positive float numbers with up to 2 decimal places.

code I have now...

<input type='number' min='.01' ng-model='threshold' />


You could use the pattern attribute to set a proper regular expression. For example:

<input name="x" pattern="[0-9]+(\.[0-9][0-9]?)?" placeholder="000.00" />