mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2025-12-20 09:11:40 +01:00
* Improved interactive select validation, now validating also on click (via option or select, inconsistent across browsers); doesn't work in Safari, which doesn't trigger a click event at all on select elements; fixes http://plugins.jquery.com/node/11520
This commit is contained in:
6
jquery.validate.js
vendored
6
jquery.validate.js
vendored
@@ -233,8 +233,12 @@ $.extend($.validator, {
|
||||
}
|
||||
},
|
||||
onclick: function(element) {
|
||||
// click on selects, radiobuttons and checkboxes
|
||||
if ( element.name in this.submitted )
|
||||
this.element(element);
|
||||
// or option elements, check parent select in that case
|
||||
else if (element.parentNode.name in this.submitted)
|
||||
this.element(element.parentNode)
|
||||
},
|
||||
highlight: function( element, errorClass, validClass ) {
|
||||
$(element).addClass(errorClass).removeClass(validClass);
|
||||
@@ -301,7 +305,7 @@ $.extend($.validator, {
|
||||
}
|
||||
$(this.currentForm)
|
||||
.delegate("focusin focusout keyup", ":text, :password, :file, select, textarea", delegate)
|
||||
.delegate("click", ":radio, :checkbox", delegate);
|
||||
.delegate("click", ":radio, :checkbox, select, option", delegate);
|
||||
|
||||
if (this.settings.invalidHandler)
|
||||
$(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
|
||||
|
||||
Reference in New Issue
Block a user