0

I am getting the above error. I want to validate the textbox which allow some special characters but not letters and numbers. For that I wrote the below code but it is giving the above error.

The code

<asp:TextBox ID="txtTag" runat="server" Width="250"></asp:TextBox>&nbsp;&nbsp;&nbsp;
<asp:RegularExpressionValidator ID="reg1" runat="server"
    ControlToValidate="txtTag" ErrorMessage="*" Text="please check" 
    ValidationExpression="/^[[\]'/\\@ &(){}+$%#=~"-`/*.&]([[\]'/\\@ &(){}+$%#=~"-`/*.&]*)$/" />

What am I doing wrong?

4

2 回答 2

0

转义ValidationExpressionwith中的引号&quot;

ValidationExpression="/^[[\]'/\\@ &(){}+$%#=~&quot;-/*.&]([[]'/\@ &(){}+$%#=~&quot;-/*.&]*)$/"

否则它们会与外部引号发生冲突。

于 2012-12-29T11:11:00.817 回答
0

利用

/^[[\]'/\\@ &amp;(){}+$%#=~&quot;-/*.&amp;]([[]'/\@ &amp;(){}+$%#=~&quot;-/*.&amp;]*)$/

作为ValidationExpression.

于 2012-12-29T11:11:43.717 回答