Skip to content

Commit d3f9b46

Browse files
AdamTibijzaefferer
authored andcommitted
Calling validate on a long form on IE7 will cause the "Script is taking too long" to display after sometime. This is tested with jQuery 1.4.4 and Validation Plugin 1.8.1
When investigating the library itself the problem turned to be that this line is causing the slowness: this.find("input, button"). The code modifications make the caches the jQuery object rather than querying again, thus, saving valuable resources.
1 parent 47cbaa2 commit d3f9b46

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

jquery.validate.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,16 @@ $.extend($.fn, {
3737

3838
if ( validator.settings.onsubmit ) {
3939

40+
var inputsAndButtons = this.find("input, button");
41+
4042
// allow suppresing validation by adding a cancel class to the submit button
41-
this.find("input, button").filter(".cancel").click(function() {
43+
inputsAndButtons.filter(".cancel").click(function () {
4244
validator.cancelSubmit = true;
4345
});
4446

4547
// when a submitHandler is used, capture the submitting button
4648
if (validator.settings.submitHandler) {
47-
this.find("input, button").filter(":submit").click(function() {
49+
inputsAndButtons.filter(":submit").click(function () {
4850
validator.submitButton = this;
4951
});
5052
}

0 commit comments

Comments
 (0)