IE7 regex issue - Regex that work in every browser does not work in ie7

邮差的信 提交于 2020-01-11 09:17:06

问题


I have a regex validating a password value to be > 6 < 25 characters with at least one number.

var passwordRegEx = /^(?=.*\d)(?=.*[a-zA-Z]).{6,25}$/;
if(!#quickRegister_Password').val().test(pass))
{
   errorMgs += 'Your password must be at least 6 characters and have at least 1 number and 1 letter.\r\n';
}

It works in Firefox, Chrome, IE8 (IE7 ran from compatability in IE8) but not IE7 standalone.


回答1:


I think you have run into the regular expression lookahead bug in IE7's javascript engine.

Run the tests on this page and see if your results match up; you will probably see the lookahead tests fail: http://www.javascriptjedi.com/regex/tests/

Information:

  • http://development.thatoneplace.net/2008/05/bug-discovered-in-internet-explorer-7.html
  • http://blog.stevenlevithan.com/archives/regex-lookahead-bug
  • http://forums.asp.net/p/1405215/3056174.aspx


来源:https://stackoverflow.com/questions/3999733/ie7-regex-issue-regex-that-work-in-every-browser-does-not-work-in-ie7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!