如何将这两个正则表达式组合用于 angularjs 表单字段
\d{4}([- ]*)\d{6,7}
或者
[a-zA-Z0-9]{4,12}
我尝试过这样
<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">
最佳答案
为了获得 2 个正则表达式的替代,您需要将它们都括在括号中:
<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">
关于javascript - 结合 angularjs 表单字段的两个正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37088506/