Reputation: 66470
I need to validate input type text that doesn't contain these characters " ' < >
I've tried:
pattern=".*[^"'<>].*"
and
pattern="[^"'<>]+"
but they don't work. It appears valid if there is one valid character.
Upvotes: 1
Views: 966
Reputation: 36101
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="^[^"'<>]+$"
Upvotes: 2