Skip to content

Instantly share code, notes, and snippets.

@jmm
Created March 17, 2012 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmm/2066187 to your computer and use it in GitHub Desktop.
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
$( "#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 );
}
} );
@jmm
Copy link
Author

jmm commented Mar 17, 2012

See jquery-validation/jquery-validation#141

I think this function could alternatively be passed to jQuery.validator.setDefaults().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment