Backslash escaping in RegularExpressionValidator

Posted by frogbot on Stack Overflow See other posts from Stack Overflow or by frogbot
Published on 2010-03-16T09:49:12Z Indexed on 2010/03/16 9:56 UTC
Read the original article Hit count: 318

Filed under:
|

I need to ensure that the input value contains at least one dot, so i use the following:

<asp:RegularExpressionValidator runat="server" ControlToValidate="MyInput" Text="*" ErrorMessage="must contain at least one dot" ValidationExpression="\.+" />

And that doesn't work. By inspecting the page source i can see that ASP.NET escapes the backslash character so in java-script it looks like "\\.+". Why does it do so and how do i prevent RegularExpressionValidator from escaping it?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about regex