问题描述:

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;'<>]+$"
相关阅读:
Top