本文介绍了RegularExpressionValidator和Regex结果不同[已解决]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过RegularExpressionValidator控件进行测试:
Testing Through RegularExpressionValidator control:
<asp:TextBox ID="TextBox1" runat="server"
ValidationGroup="Regex"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="Invalid"
ValidationExpression="[0-9]{0,5}" ValidationGroup="Regex"></asp:RegularExpressionValidator>
<asp:Button ID="btnTestRegex" runat="server" Text="Valid Or Not?"
ValidationGroup="Regex" />
输入:
TextBox1.Text ="1a";
输出:
无效.
------------------------------- ****** ------------- --------------------
通过编码:
Input:
TextBox1.Text = "1a";
Output:
Invalid.
-------------------------------******---------------------------------
Through Coding :
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Label ID="lblValid" runat="server" Text="Valid" Visible="false"></asp:Label>
<asp:Label ID="lblInvalid" runat="server" Text="Invalid" Visible="false"></asp:Label>
<asp:Button ID="Button3" runat="server" onclick="Button2_Click" Text="Button" />
输入:
TextBox1.Text ="1a";
输出:
有效.
----------------------------------- ********* ------ ----------------------
谁能说出为什么这表现出不同????
Input:
TextBox1.Text = "1a";
Output:
Valid.
-----------------------------------*********----------------------------
Can anyone tell why this is behaving differently????
推荐答案
这篇关于RegularExpressionValidator和Regex结果不同[已解决]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!