Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cfmitrah/c4c02b898c9cd281c3ac to your computer and use it in GitHub Desktop.
Save cfmitrah/c4c02b898c9cd281c3ac to your computer and use it in GitHub Desktop.
jQuery validation error placement for Semantic-UI
jQuery(document).ready(function($) {
$.validator.setDefaults({
errorClass: 'errorField',
errorElement: 'div',
errorPlacement: function(error, element) {
error.addClass("ui red pointing above ui label error").appendTo( element.closest('div.field') );
},
highlight: function(element, errorClass, validClass) {
$(element).closest("div.field").addClass("error").removeClass("success");
},
unhighlight: function(element, errorClass, validClass){
$(element).closest(".error").removeClass("error").addClass("success");
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment