[英]angulajs ng-pattern validator for input field
I am working with angularjs form validations, where i have few fields need to validate them, i will only allow the user to enter input starting with certain mix of characters and numbers(will be 7 after characters)like BID0001234, Q0001234 and PO0001234. 我正在使用angularjs表单验证,在这里我需要验证的字段很少,我将只允许用户输入以某些字符和数字混合开头的输入(字符后为7),例如BID0001234,Q0001234和PO0001234。 In this case(BID0001234) i have tried these patterns '^BID/[0-9\\d] $/','^BID/^[0-9\\d] $/' and '^BID/^[0-9\\d]+$/'.
在这种情况下(BID0001234)我尝试了以下模式'^ BID / [0-9 \\ d] $ /','^ BID / ^ [0-9 \\ d] $ /'和'^ BID / ^ [0- 9 \\ d] + $ /”。 for some reason unable to validate it, could you someone please share the experience or direct me towards a regex pattern link that matches my issue.
由于某种原因无法验证它,您能不能请他人分享经验或将我定向到与我的问题匹配的regex模式链接。
update: I want to count the numbers after the BID as well, seven numbers are accepted 更新:我也想计算BID之后的数字,可以接受七个数字
Any help is much appreciated 任何帮助深表感谢
No need for the slashes. 不需要斜线。 Try
尝试
ng-pattern="'^BID[0-9]+$'"
For exactly seven digits after "BID": 对于“出价”之后的准确七位数:
ng-pattern="'^BID[0-9]{7}$'"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.