I have an HtmlTextArea and I want to limit the number of characters that users can enter up to 500.
I have currently used RegularExpressionValidator ...
RegularExpressiondValidator val = new RegularExpressiondValidator ();
val.ValidationExpression = "^.{0,500}$";
val.ControlToValidate = id;
val.ErrorMessage = "blah";
... this is great when the text is entered on one line, but it instantly fails to check whenever the text contains a new string character (i.e. multi-line).
I understand that there are different regex mechanisms, and I need to test .NET. (can someone point me in the direction of good online?), but I tried a couple of other things, including guesses "(? m)" in my expression string and replacing ^ and $ with \ A and \ Z, but still bad luck.
Another related question is, can I not use the regex at all and associate this validator with my own validation function somehow?
Ben l source
share