我编写了一个正则表达式,并尝试匹配输入文本是否与其匹配。
var inputtxt = document.fd.pwd;
var decimal= /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{8,20}$/;
if(inputtxt.value.match(decimal))
{
alert("Your Password confirms to New Password Rules.");
}
else
{
alert("Your Password must contain atleast one each of following: \n\t 1 Uppercase alphabet \n\t 2 Lowercase alphabet \n\t 3 Digit[0-9] \n\t 4 Special Character[ie !,@,#,$ etc] \n\n It SHOULD NOT conatin any Blank spaces ");
}
此代码在 FF/CHrome/IE8+ 中完美运行,但在 IE6 中不起作用。
最佳答案
Windows XP 是唯一仍支持 IE6 的 Windows 平台。对 Windows XP 的支持结束于...好吧,自己看看 here .
IE6 的全局使用率非常低(在中国以外),可以忽略它而不会产生太多副作用(有点像大多数人甚至不知道的所有低使用率浏览器)。
换句话说,支持 IE6 的投资返回实在是太糟糕了,根本无法考虑这样做。只需放弃支持并继续您的生活,您将节省时间和金钱。
关于Javascript 正则表达式 match() 在 IE6 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22906083/