I have an HtmlTextArea and I want to restrict the number of characters users can input to 500.
Currently I've used a RegularExpressionValidator...
RegularExpressiondValidator val = new RegularExpressiondValidator ();
val.ValidationExpression = "^.{0,500}$";
val.ControlToValidate = id;
val.ErrorMessage = "blah";
... this is fine when the text is entered on a single line but it instantly fails validation whenever the text includes a new line character (ie. is multi-line).
I realise there are different regular expression engines and I need to test with the .NET one (can anyone point me in the direction of a good one online?) but I've tried a couple of other things including prepending "(?m)" to my expression string, and replacing ^ and $ with \A and \Z but so far no luck.
A further related question, can I avoid using a regular expression at all and link this validator to my own validation function somehow?