How to combine this two regex for angularjs form field
\d{4}([- ]*)\d{6,7}
OR
[a-zA-Z0-9]{4,12}
I tried like this
<input type="text" pattern="\d{4}([- ]*)\d{6,7} | [a-zA-Z0-9]{4,12}" class="form-control" ng-model="formData.username" required placeholder="username">
patternis a HTML5 attribute, and you cannot have spaces around|. You can try withng-pattern="/^(\d{4}([- ]*)\d{6,7}|[a-zA-Z0-9]{4,12})$/"