Created
July 2, 2012 03:56
-
-
Save dennysfredericci/3030983 to your computer and use it in GitHub Desktop.
An easy way to use JQuery Validation with Twitter Bootstrap Popover
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('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'); | |
}); | |
} | |
}); |
In case anyone's wondering it would be _popover.data('bs.popover').options.content = value.message;
with Bootstrap 3
Pfffew, i was looking for a solution like this for 20 minutes... Thank you Dennys !
And yep, "i was wondering", thank you mcsheffrey ;)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you provide some insight on implementing this with the bootstrap-wysihtml5 textarea editor (http://jhollingworth.github.io/bootstrap-wysihtml5/)?