Hi!
I believe it is a simple question. :)
In my ASP.NET Web Form I have a multiline TextBox
which should be validated with RegularExpression Validator. Text box should contain one ore more strings "a" (just 'a' char, nothing else).
So far I got these regular expressions for my RegularExpressionValidator
object:
(?m:(^a$)+)
(?m:\A(^a$)+\Z)
(?m:^a$)
and some others... Neither works. :) Guess there is something fundamental I'm not getting yet.
Could you please tell me where I'm wrong? And what to read so I won't ask such stupid questions again? :)
Thanks!
UPD:
Here's the code involved.
A Button (just for postbacks):
<asp:Button ID="Button1" runat="server" Text="Button" />
The TextBox:
<asp:TextBox ID="TextBox1" runat="server" Rows="10" TextMode="MultiLine"></asp:TextBox>
And the regex validator:
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="RegularExpressionValidator"
ValidationExpression="(?m:(^a$)+)"></asp:RegularExpressionValidator>
There is nothing else on that Web Form. I've only added those controls and modified properties. I've even did all this using VS GUI.
UPD2:
Using CustomValidator and doing Regex.Match(TextBox1, @"(?m:(^a$)+)")
in it works just fine. Something is wrong with RegularExpressionValidator I guess.