Skip to content

Instantly share code, notes, and snippets.

@scastiel
Created June 26, 2014 13: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 scastiel/2034119a5ffe6b0350de to your computer and use it in GitHub Desktop.
Save scastiel/2034119a5ffe6b0350de to your computer and use it in GitHub Desktop.
Use jQuery Validation plugin with Bootstrap
$('#form').validate({
errorPlacement: function(error, element) {
error.appendTo(element.parent(".form-group").find('.help-block'));
},
errorElement: 'span',
errorClass: 'has-error',
validClass: 'has-success',
highlight: function(element, errorClass, validClass) {
$(element).parents('.form-group').addClass(errorClass).removeClass(validClass);
},
unhighlight: function(element, errorClass, validClass) {
$(element).parents('.form-group').removeClass(errorClass).addClass(validClass);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment