Reputation: 253
I have this little code:
alert(1);
$('input[name^="Quantity_"]').each(function () {
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
Upvotes: 1
Views: 1217
Reputation: 29658
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.
Upvotes: 2