Skip to content

Instantly share code, notes, and snippets.

@briansteeleca
Created October 22, 2014 19:15
Show Gist options
  • Save briansteeleca/3d35d9bd7112feda3809 to your computer and use it in GitHub Desktop.
Save briansteeleca/3d35d9bd7112feda3809 to your computer and use it in GitHub Desktop.
Accessible form error focus solution with jQuery Validation (from Katie) #jquery #validation #accessibility #errors #katie
// http://stackoverflow.com/questions/1218118/overriding-a-function-within-the-jquery-validation-plugin
$("form#user-register").validate({
// focus will normally go to the last error
// but this will make it go to the first!
invalidHandler: function(form, validator){
$(validator.invalidElements()[0]).focus();
},
focusInvalid:false
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment