2011-05-12 104 views
3

使用jQuery 1.5.2越來越JavaScript錯誤:在IE 7 jQuery驗證導致錯誤和8

Error: '$.validator.methods[...]' is null or not an object 

我在IE7和IE8進行了測試,並得到了錯誤。驗證在Firefox 4及更早版本中正常工作。

當從地址1字段切換到地址2字段..實際上,當從地址1中點擊信息到沒有信息的地址2時。另外......當從Zip字段中選擇Tab鍵或點擊字段到縣字段時,我很奇怪我沒有在Zip和/或County中輸入或輸出信息的錯誤......另外,zip字段對它沒有maskedinput驗證。我正在使用jQuery 1.4.2,並看到類似問題 (Jquery Validator not working in IE 7 or 8)的回覆。 我正在使用jQuery 1.4.2,並獲得1.5.2的相同結果。

這是我的驗證碼。

$('#frm_subefoLocation').validate({ 
    rules: { 
    address1: { require:true,maxlength:100,minlength:2}, 
    address2: { require:false,maxlength:100}, 
    city: { require:true,maxlength:100,minlength:2}, 
    zip: { required:true,minlength:5,maxlength:10,number:true}, 
    county: { require:false,maxlength:100,minlength:0}, 
    mailAddress1: { require:true,maxlength:100,minlength:2}, 
    mailAddress2: { require:false,maxlength:100,minlength:0}, 
    mailCity: { require:true,maxlength:100,minlength:2}, 
    mailZip: { required:true,minlength:5,maxlength:10,number:true} 
    } 
}); 

這裏是屏蔽輸入代碼:

// set up mask for entry 
$('#zip').mask('99999'); 

任何想法?

+0

格式化您的代碼將有助於人們想要回答你。 – alex 2011-05-12 00:19:52

+0

嗨@Chris我繼續前進,並將代碼格式化。您可能希望包含指向您正在使用的驗證插件的鏈接。您可能還想嘗試用更加面向未來的h5validate插件進行驗證。 – Gabriel 2011-05-12 00:25:05

+0

Gabriel,感謝格式化...試圖找到格式化標籤,但沒有...我希望有人知道一個解決方案......這是遍佈一個巨大的報告網站猖獗......如果需要將會改變,但是..:| – Chris 2011-05-12 00:48:53

回答

1

看着今天早上的代碼,我注意到......'require'是不允許的......'必需的'是必需的。「 這個區別並沒有打擾Firefox,但確實與IE混淆了。

+0

那是解決方案嗎? – 2011-05-12 17:43:44