javascript - What is the quickest way to allow only integers (and restricting decimals) using HTML 5 and angularJs -
i have text input, receive ids. allow integers.
the following code doesn't allow special characters allows float/decimals:
<input type="number" class="form-control input-sm ng-touched ng-dirty ng-valid ng-valid-number" name="idcliente" id="idcliente" placeholder="id cliente" ng-model="vm.idcliente" ng-pattern="/^[0-9]*$/" ng-class="{'error': panelcontrol.idcliente.$error.pattern}">
what's quickest way restrict decimals in client side?
you need add function that fire on keyup event , return true or false depending on results of operation num % 1 != 0
. may show warning adding error class input and/or changing model value null
.
p.s.
using regex such trivial purpose that's not idea performance point of view.
Comments
Post a Comment