在 ng-pattern
中,我们可以选择指定字段应匹配特定模式。
我们如何指定它不应该匹配指定的模式?
例子,
<input type="text" ng-pattern="/[*|\":<>[\]{}`()';@&$]/" />
在这里,我不希望字段匹配模式。相反,如果模式匹配,我想显示错误。
最佳答案
您可以使用否定环视 ((?!pattern)
) 来否定您的正则表达式:
ng-pattern="/(?![*|\":<>[\]{}`()';@&$])/"
关于javascript - ng-pattern 不应匹配提供的模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34591323/