[英]ng-pattern for password text to accept all special characters and numbers, alphabets
Html HTML
<form novalidate class="css-form">
username <input type="text"
ng-pattern="/^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@('@')$!%*#?&])[A-Za-z\d$@('@')$!%*#?&]{8,20}$/" ng-model="user.email" required /><br />
</form>
Above pattern is working fine for below symbols 上方图案对下方符号正常工作
@ # $ % & ! *
But I want to allow all special characters like 但我想允许所有特殊字符
{ } [ ] < > ( ) ^ + - = ; : ' " / \ |
How to include all special characters in that pattern that should work for password? 如何在该模式中包含所有适用于密码的特殊字符?
Use the following ng-pattern
: 使用以下
ng-pattern
:
ng-pattern="/^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@('@')$!%*#?&{}[\]<>()^+=;:'"/\\|-])[A-Za-z\d$@('@')$!%*#?&{}[\]<>()^+=;:'"/\\|-]{8,20}$/"
Note that \\
and ]
are escaped in the character class with \\
and the double quotes are represented as a "
请注意,字符类中的
\\
和]
使用\\
进行转义,双引号表示为"
HTML entity. HTML实体。 The hyphen does not need escaping when at the character class end .
在字符类末尾 ,连字符不需要转义。
See the updated plunkr . 请参阅更新的plunkr 。
在每个特殊符号前用“ \\”字符转义特殊符号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.