1
我寫了一個RegEx並試圖匹配輸入文本是否與它匹配。Javascript正則表達式匹配()在IE6中不起作用
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 /鉻/ IE8 +但在IE6不工作。
讓IE6死亡! – rekire
如果你想支持IE6,你最好不要在JavaScript中嘗試任何奇妙的東西......你不能有一個服務器端驗證後備? (無論如何你可能會需要這個) – rednaw
可能不支持lookahead。雖然不難解決。 – RobG