JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app ng-controller="myCtrl">
<form name="myForm">
<input type="number" ng-pattern="onlyNumbers" ng-model="value" name="number" max="999"/>
Valid? {{myForm.number.$valid}}
</form>
</div>
CSS
.red {
color: red;
}
.black {
color: black;
}
JavaScript
function myCtrl($scope) {
$scope.onlyNumbers = /^\d+$/;
}