仅针对密码/邮政编码的数字输入无效。我在jsp页面和控制器中使用了ng-pattern,如下所示:
Jsp页面:
Pin:<input type="text" class="form-control input-sm" ng-pattern="numOnlyRegex" name="pin" required placeholder="Pin"/><br/>
模块:
var app = angular.module('myApp',[]);
控制器:
app.controller("numOnlyRegex",function($scope)
{
$scope.numOnlyRegex = /^\d+$/;
});
js的scr文件夹是:
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="${pageContext.request.contextPath}/myAppRegistrationModule.js"></script>
<script src="${pageContext.request.contextPath}/numOnlyRegex.js"></script>