mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2025-12-20 09:11:40 +01:00
Bugfixes for compability with jQuery 1.4.2, while maintaining backwards-compability
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
* Renamed phone-method in additional-methods.js to phoneUS
|
* Renamed phone-method in additional-methods.js to phoneUS
|
||||||
* Added phoneUK and mobileUK methods to additional-methods.js (http://plugins.jquery.com/node/12359)
|
* Added phoneUK and mobileUK methods to additional-methods.js (http://plugins.jquery.com/node/12359)
|
||||||
* Deep extend options to avoid modifying multiple forms when using the rules-method on a single element (http://plugins.jquery.com/node/12411)
|
* Deep extend options to avoid modifying multiple forms when using the rules-method on a single element (http://plugins.jquery.com/node/12411)
|
||||||
|
* Bugfixes for compability with jQuery 1.4.2, while maintaining backwards-compability
|
||||||
|
|
||||||
1.6
|
1.6
|
||||||
---
|
---
|
||||||
|
|||||||
18
jquery.validate.js
vendored
18
jquery.validate.js
vendored
@@ -300,12 +300,13 @@ $.extend($.validator, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function delegate(event) {
|
function delegate(event) {
|
||||||
var validator = $.data(this[0].form, "validator");
|
var validator = $.data(this[0].form, "validator"),
|
||||||
validator.settings["on" + event.type] && validator.settings["on" + event.type].call(validator, this[0] );
|
eventType = "on" + event.type.replace(/^validate/, "");
|
||||||
|
validator.settings[eventType] && validator.settings[eventType].call(validator, this[0] );
|
||||||
}
|
}
|
||||||
$(this.currentForm)
|
$(this.currentForm)
|
||||||
.delegate("focusin focusout keyup", ":text, :password, :file, select, textarea", delegate)
|
.validateDelegate(":text, :password, :file, select, textarea", "validatefocusin validatefocusout keyup", delegate)
|
||||||
.delegate("click", ":radio, :checkbox, select, option", delegate);
|
.validateDelegate(":radio, :checkbox, select, option", "click", delegate);
|
||||||
|
|
||||||
if (this.settings.invalidHandler)
|
if (this.settings.invalidHandler)
|
||||||
$(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
|
$(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
|
||||||
@@ -1104,8 +1105,8 @@ $.format = $.validator.format;
|
|||||||
// provides triggerEvent(type: String, target: Element) to trigger delegated events
|
// provides triggerEvent(type: String, target: Element) to trigger delegated events
|
||||||
;(function($) {
|
;(function($) {
|
||||||
$.each({
|
$.each({
|
||||||
focus: 'focusin',
|
focus: 'validatefocusin',
|
||||||
blur: 'focusout'
|
blur: 'validatefocusout'
|
||||||
}, function( original, fix ){
|
}, function( original, fix ){
|
||||||
$.event.special[fix] = {
|
$.event.special[fix] = {
|
||||||
setup:function() {
|
setup:function() {
|
||||||
@@ -1125,16 +1126,13 @@ $.format = $.validator.format;
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
$.extend($.fn, {
|
$.extend($.fn, {
|
||||||
delegate: function(type, delegate, handler) {
|
validateDelegate: function(delegate, type, handler) {
|
||||||
return this.bind(type, function(event) {
|
return this.bind(type, function(event) {
|
||||||
var target = $(event.target);
|
var target = $(event.target);
|
||||||
if (target.is(delegate)) {
|
if (target.is(delegate)) {
|
||||||
return handler.apply(target, arguments);
|
return handler.apply(target, arguments);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
|
||||||
triggerEvent: function(type, target) {
|
|
||||||
return this.triggerHandler(type, [$.event.fix({ type: type, target: target })]);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<input type="password" name="pw1" id="pw1" value="engfeh" />
|
<input type="password" name="pw1" id="pw1" value="engfeh" />
|
||||||
<input type="password" name="pw2" id="pw2" value="" />
|
<input type="password" name="pw2" id="pw2" value="" />
|
||||||
</div>
|
</div>
|
||||||
<div id="main" style="display:none;">
|
<div id="main" style="position: absolute; top: -10000px; left: -10000px;">
|
||||||
<p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> for more information.</p>
|
<p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> for more information.</p>
|
||||||
<p id="ap">
|
<p id="ap">
|
||||||
Here are some links in a normal paragraph: <a id="google" href="http://www.google.com/" title="Google!">Google</a>,
|
Here are some links in a normal paragraph: <a id="google" href="http://www.google.com/" title="Google!">Google</a>,
|
||||||
|
|||||||
18
test/test.js
18
test/test.js
@@ -574,15 +574,9 @@ test("findLastActive()", function() {
|
|||||||
ok( !v.findLastActive() );
|
ok( !v.findLastActive() );
|
||||||
v.form();
|
v.form();
|
||||||
v.focusInvalid();
|
v.focusInvalid();
|
||||||
ok( !v.findLastActive() );
|
equals( v.findLastActive(), $("#firstname")[0] );
|
||||||
try {
|
var lastActive = $("#lastname").trigger("validatefocusin")[0];
|
||||||
$("#testForm1 input:last").trigger("focusin");
|
equals( v.findLastActive(), lastActive );
|
||||||
//$("#testForm1").triggerEvent("focusin", $("#testForm1 input:last")[0]);
|
|
||||||
v.focusInvalid();
|
|
||||||
equals( lastInput, v.findLastActive() );
|
|
||||||
} catch(e) {
|
|
||||||
ok( true, "Ignore in IE" );
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("validating multiple checkboxes with 'required'", function() {
|
test("validating multiple checkboxes with 'required'", function() {
|
||||||
@@ -877,7 +871,7 @@ test("validate on blur", function() {
|
|||||||
equals(v.errors().filter(":visible").size(), expected);
|
equals(v.errors().filter(":visible").size(), expected);
|
||||||
}
|
}
|
||||||
function blur(target) {
|
function blur(target) {
|
||||||
target.trigger("focusout");
|
target.trigger("validatefocusout");
|
||||||
}
|
}
|
||||||
$("#errorFirstname").hide();
|
$("#errorFirstname").hide();
|
||||||
var e = $("#firstname");
|
var e = $("#firstname");
|
||||||
@@ -954,7 +948,7 @@ test("validate on not keyup, only blur", function() {
|
|||||||
e.trigger("keyup");
|
e.trigger("keyup");
|
||||||
e.keyup();
|
e.keyup();
|
||||||
errors(0);
|
errors(0);
|
||||||
e.trigger("focusout");
|
e.trigger("validatefocusout");
|
||||||
errors(1);
|
errors(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -968,7 +962,7 @@ test("validate on keyup and blur", function() {
|
|||||||
e.val("a");
|
e.val("a");
|
||||||
e.trigger("keyup");
|
e.trigger("keyup");
|
||||||
errors(0);
|
errors(0);
|
||||||
e.trigger("focusout");
|
e.trigger("validatefocusout");
|
||||||
errors(1);
|
errors(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user