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
Be sure you call
$("#YourForm").validate()before using therulesmethod, as per the documentation: http://docs.jquery.com/Plugins/Validation/rules#.22add.22rules. In your case, I’d use that call beforealert(1)or wherever you want to initialize your code.Replace
#YourFormwith whatever selector you want.