Created
March 17, 2012 23:02
-
-
Save jmm/2066187 to your computer and use it in GitHub Desktop.
Workaround for lack of click event support for OPTIONs in OPTGROUPs in jQuery Validation Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$( "#some-form" ).validate( { | |
'onclick' : function ( element, event ) { | |
var parent; | |
if ( | |
( parent = $( element ).filter( "option" ).closest( "select" ) ).length | |
) { | |
element = parent[0]; | |
} | |
// if | |
$.validator.defaults.onclick.call( $( element.form ).data( 'validator' ), element, event ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See jquery-validation/jquery-validation#141
I think this function could alternatively be passed to
jQuery.validator.setDefaults()
.