我正在關注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