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]+;).)*$
{1}? It's redundant. I'm not sure what that's meant to do, but{x}doesn't do anything unless x is 2 or greater.< script>will get past your pattern because of the whitespace. Use a real HTML parser instead.< script src="http://foo.bar">is valid HTML. The whitespace after the<doesn't matter.