Skip to content

Instantly share code, notes, and snippets.

@craigmdennis
Last active August 29, 2015 14:05
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 craigmdennis/abad157062b4c0e74817 to your computer and use it in GitHub Desktop.
Save craigmdennis/abad157062b4c0e74817 to your computer and use it in GitHub Desktop.
Allow jQuery Validate to mark Chosen select box as valid
# Allow jQuery Validate to run validation on jQuery Chosen
# select boxes by changing the ignore selector from `:hidden`
$.validator.setDefaults
ignore: '.no-validate'
# jQuery Validate doesn't mark fields as valid on hidden elements
# So when using Chosen we need to show the original input,
# give it focus and then hide it again
$('.js-chosen-select').on 'change', ->
$(this).show().css
'position' : 'absolute'
'left': '-9999px'
'opacity' : '0'
.focus()
.attr('style','')
.hide()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment