I want one of my input fields to have exactly 10 digits. I have used ng-pattern
in following manner
<input type="text" ng-pattern="/[1-9]{1}[0-9]{9}$/" ng-model="user.Identity" name="identity">
The problem is that this expression is allowing the user to enter numeric strings having more than 10 digits whereas, I want to allow exactly 10 digits. Is there a problem with my regex or my understanding of ng-pattern
?
^
锚指示字符串/行的开始,就像$
代表结束一样, ^expr$
防止移位窗口与您看到的匹配:
/^[1-9]{1}[0-9]{9}$/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.