Reputation: 4061
I've been trying to read about and test various regular expression testers to find my solution but to no avial. I'm using:
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
ErrorMessage='<%# "*"%>' ValidationExpression="," runat="server"
ControlToValidate="edit_email" Display="Dynamic"
EnableClientScript="true"></asp:RegularExpressionValidator>
All I want to do is find out if there is a comma in the textbox, which this leads me to believe it would do. I tested this on http://www.regular-expressions.info/javascriptexample.html, as I understand that EnableClientScript="true"
means I need to have JavaScript compliant RegEx
Any help would be greatly appreciated, here are the other things I've tried:
ValidationExpression=".*\,"
Which
only hides the error message when I
have a string followed by a comma at
the end: "123,"ValidationExpression=".*,"
Which only hides the error message when I have a string like: "123,"ValidationExpression=","
Which only hides the error message when I have a string like: "," (only one character, and MUST be a comma)ValidationExpression="[^,]"
Which only hides the error message when I have a string like: "1" (only one character, and must NOT be a comma)ValidationExpression="/,/"
Which never hides the error messageUpvotes: 2
Views: 1972
Reputation: 8979
How about .*,.*
? Do you want to know if there is at least one comma or exactly one comma?
Upvotes: 1
Reputation: 54150
Try this:
ValidationExpression="[^,]*"
That means "zero or more characters, none of which may be a comma"
Upvotes: 4