Reputation: 4875
I'd like to use a asp:RegularExpressionValidator
where the ValidatorExpression
is a regex that matches all strings that do not contain an ampersand. Google fu didn't yield much, but I'm sure it's probably not too complicated.
<asp:RegularExpressionValidator
ID="StringValidator1"
runat="server"
ControlToValidate="textBox1"
ValidationExpression="???"
Display="Dynamic"
ErrorMessage="String cannot contain ampersands"
ValidationGroup="Group1"
/>
Thanks.
Upvotes: 0
Views: 442
Reputation: 336098
ValidationExpression = "^[^&]*$"
matches any string that doesn't contain an ampersand.
Explanation:
^ # Start of string
[^&]* # Any number of characters that are not ampersands
$ # End of string
Upvotes: 3