Javascript 在.Net 1.1上使用两次正向前瞻不起作用
我使用RegularExpressionValidator控件验证名为TextBox1的TextBox控件,这是VS2003 web应用程序中的web表单,如下所示:Javascript 在.Net 1.1上使用两次正向前瞻不起作用,javascript,.net,regex,Javascript,.net,Regex,我使用RegularExpressionValidator控件验证名为TextBox1的TextBox控件,这是VS2003 web应用程序中的web表单,如下所示: <asp:TextBox id="TextBox1" runat="server"></asp:TextBox> <asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ErrorMessage="
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ErrorMessage="Fromat error."
ValidationExpression="^(?=.*[0-9])(?=.*[a-zA-Z]).{8,10}$" ControlToValidate="TextBox1"></asp:RegularExpressionValidator>
…在JavaScript中匹配。如何修复它?试试这个正则表达式:
^(?=.{8,10}$)(?=.*[0-9])(?=.*[a-zA-Z]).+$
旧版本的InternetExplorer(如上所述)中存在一个bug,导致这样的正则表达式在客户端失败,即使它在服务器上工作。(这听起来与您描述的正好相反,但我看不出您的正则表达式会失败的任何其他原因。)将长度检查移到第一个前瞻是解决该错误的行之有效的方法。谢谢您的回答。是的,我尝试使用IE6/7/8/9浏览,IE6/7失败,但IE8/9是正确的。用你的答案,IE6/7/8/9是正确的。谢谢
^(?=.{8,10}$)(?=.*[0-9])(?=.*[a-zA-Z]).+$