I need to implement regular expressions in AngularJs that will accept the following three statements:
09344542525 -> 11 digit number starting with 09
02144532363 -> 11 digit number starting with 021
44532363 -> 8 digit number
Below is my HTML :
<div class="container co-operate" ng-controller="cooperationController">
<form novalidate name="cooperationForm" class="signinform">
<div class="form-group inner-addon right-inner-addon">
<label class="form-label control-label"></label>
<input ng-model="restaurantInformation.tel" type="text" name="tel" id="tel" placeholder="phone number"
ng-pattern="mobRegEx || prePhoneRegEx || phoneRegEx" class="form-control default-input singleline-input" required />
<span class="form-icon icon icon-avatar"></span>
</div>
<p ng-show="cooperationForm.tel.$error.pattern" style="color: red">Wrong number format</p>
</form>
</div>
Angular:
app.controller('cooperationController', function ($scope) {
$scope.mobRegEx = '/09[0-3][0-9]{8}/';
$scope.prePhoneRegEx = '/021[0-9]{8}/';
$scope.phoneRegEx = '[0-9]{8}';
.
.
.
}
Currently, even after inputting an integer and testing it, the error paragraph always shows an error. Any suggestions on modifying the regular expression?