开发者

Mysterious error with jQuery validate and IE7

I have this little code:

alert(1);
$('input[name^="Quantity_"]').each(function () {
   开发者_如何学JAVA alert(2);
    $(this).rules("add", { required: true, digits: true });
    alert(3);
});
alert(4);

In Chrome or Firefox, I see the alert 1, 2, 3 and 4, but with IE7, I see only the alert 1 & 2. Why the script failed on rules()?

IE7 doesn't report an error in the page

EDIT 1: The javascript failed on the line $.data(element.form, 'validator').settings; in jquery.validation.js script. Element.form is not null, but $.data(element.form, 'validator') is undefined.

Thank you


Be sure you call $("#YourForm").validate() before using the rules method, as per the documentation: http://docs.jquery.com/Plugins/Validation/rules#.22add.22rules. In your case, I'd use that call before alert(1) or wherever you want to initialize your code.

Replace #YourForm with whatever selector you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜