mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2025-12-20 09:11:40 +01:00
Core: Added radio/checkbox to delegate click-event
Reverts the accidental change from d319a0da35,
where these event handlers were dropped.
Closes #1126
This commit is contained in:
committed by
Jörn Zaefferer
parent
db55d36de5
commit
cda5efa487
@@ -349,7 +349,7 @@ $.extend( $.validator, {
|
||||
"focusin focusout keyup", delegate)
|
||||
// Support: Chrome, oldIE
|
||||
// "select" is provided as event.target when clicking a option
|
||||
.validateDelegate("select, option", "click", delegate);
|
||||
.validateDelegate("select, option, [type='radio'], [type='checkbox']", "click", delegate);
|
||||
|
||||
if ( this.settings.invalidHandler ) {
|
||||
$( this.currentForm ).bind( "invalid-form.validate", this.settings.invalidHandler );
|
||||
|
||||
31
test/test.js
31
test/test.js
@@ -364,6 +364,37 @@ asyncTest("validation triggered on radio/checkbox when using keyboard", function
|
||||
}, 50);
|
||||
});
|
||||
|
||||
asyncTest("validation triggered on radio/checkbox when using mouseclick", function() {
|
||||
expect( 1 );
|
||||
var input, i, events, triggeredEvents = 0;
|
||||
|
||||
$("#form").validate({
|
||||
onclick: function() {
|
||||
triggeredEvents++;
|
||||
}
|
||||
});
|
||||
|
||||
events = [
|
||||
$.Event("click")
|
||||
];
|
||||
|
||||
input = $("#form :radio:first");
|
||||
for(i = 0; i < events.length; i++) {
|
||||
input.trigger(events[i]);
|
||||
}
|
||||
|
||||
input = $("#form :checkbox:first");
|
||||
for(i = 0; i < events.length; i++) {
|
||||
input.trigger(events[i]);
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
// assert all event handlers fired
|
||||
equal(2, triggeredEvents);
|
||||
start();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
test( "showErrors()", function() {
|
||||
expect( 4 );
|
||||
var errorLabel = $( "#errorFirstname" ).hide(),
|
||||
|
||||
Reference in New Issue
Block a user