jcubic
jcubic

Reputation: 66470

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.

Upvotes: 1

Views: 966

Answers (1)

ndnenkov
ndnenkov

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="^[^&#x22;'<>]+$"

Upvotes: 2

Related Questions