我正在关注official angular documentation,但它不适用于我。什么可能是错的?我需要验证是否需要手机,并遵循国际标准如+4400000000(加上信号和数字,没有空格,只有加号后的数字)。在Regular验证表单字段与regEx
我的代码....
.controller('ModalInstanceChangeDetailsCtrl', function ($scope, $rootScope, $uibModalInstance, items) {
$scope.rxMobile = '^\+[1-9]{1}[0-9]{3,14}$';
}
<form name="form">
<div class="form-group">
<label>Mobile number</label><label class="fieldError" ng-show="form.mobile.$error.required || !form.mobile.$valid">This field is required and must use International format, ex: +440000000000</label>
<input ng-pattern="rxMobile" required ng-model="mobile" name="mobile" type="text" class="form-control">
</div>
</form>
什么建议吗?
SyntaxError:无效正则表达式:/ ^^ + d {10} $ /:无法在新的RegExp处重复 --- $ scope.rxMobile =“^ \ + \ d \ d {10} \ b” ; –
@MarcoJr检查编辑 – m87