当前位置: 动力学知识库 > 问答 > 编程问答 >

regex - How to validate string that can't have certain characters using parsley

问题描述:

I need to validate input type text that doesn't contain these characters " ' < > I've tried:

pattern=".*[^&#x22;'<>].*"

and

pattern="[^&#x22;'<>]+"

but they don't work. It appears valid if there is one valid character.

网友答案:

The problem with your current attempts is that they try to match one (or at least one) character, which is not one of the listed as undesirable characters. Instead, you should make sure this applies to all characters from the start (^) til the end ($).

pattern="^[^&#x22;'<>]+$"
分享给朋友:
您可能感兴趣的文章:
随机阅读: