Skip to content

Instantly share code, notes, and snippets.

@ScrambledBits
Forked from dennysfredericci/validator
Created November 9, 2012 03:48
Show Gist options
  • Save ScrambledBits/4043581 to your computer and use it in GitHub Desktop.
Save ScrambledBits/4043581 to your computer and use it in GitHub Desktop.
An easy way to use JQuery Validation with Twitter Bootstrap Popover
$('form').validate(
{
rules: {
numero: {
required: true
},
descricao: {
minlength: 3,
email: true,
required: true
}
},
showErrors: function(errorMap, errorList) {
$.each( this.successList , function(index, value) {
$(value).popover('hide');
});
$.each( errorList , function(index, value) {
console.log(value.message);
var _popover = $(value.element).popover({
trigger: 'manual',
placement: 'top',
content: value.message,
template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><div class="popover-content"><p></p></div></div></div>'
});
_popover.data('popover').options.content = value.message;
$(value.element).popover('show');
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment