var app = angular.module('plunker', []);
app.controller("MyCtrl", ["$scope", function ($scope) {
$scope.amount = 0;
$scope.onSubmit = function () {
alert("form submitted and Amount is -" + $scope.amount);
}
}]);
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.4.x" src="https://code.angularjs.org/1.4.12/angular.js" data-semver="1.4.9"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MyCtrl">
<div>
<form name="myNumberForm" ng-submit="onSubmit()">
<input type="number" ng-model="amount" name="amount_field"
ng-pattern="/^[0-9]{1,7}$/" required>
<span ng-show="myNumberForm.amount_field.$error.pattern">Not a valid number!</span>
<span ng-show="myNumberForm.amount_field.$error.required">This field is required!</span>
<input type="submit" value="submit" />
</form>
</div>
<h5>For more - <a href="https://code-sample.com" target="_blank"> Click this link..</a></h5>
</body>
</html>
/* Put your css in here */