Reputation:
I am using an asp RegularExpressionValidator to validate if a textarea has html or encoded html. I need the validator to work client side because I have ValidateRequest set to true on the page. My regex is set to match any string that does not have a less than character followed by an alpha character or an ampersand followed by some number of alpha characters ending in a semi-colon.
^((?![<]{1}[a-z]{1}).)*$
^((?![&]{1}[a-z]+;).)*$
Upvotes: 1
Views: 123
Reputation: 2860
Javascript does not have a concept of Single-Line which lets your period match any character including line breaks. You should use the following in place of your comma: [\s\S]
^((?![<]{1}[a-z]{1})[\s\S])*$
^((?![&]{1}[a-z]+;)[\s\S])*$
Upvotes: 2