Skip to content

Instantly share code, notes, and snippets.

@dmvk
Created March 30, 2012 21:29
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 dmvk/2255273 to your computer and use it in GitHub Desktop.
Save dmvk/2255273 to your computer and use it in GitHub Desktop.
jquery live form validation for bootstrap
Nette.addError = function(elem, message) {
var group = $('#' + elem.id).closest('.control-group');
group.removeClass('error');
group.find('.help-inline').remove();
if (message) {
group.addClass('error');
group.find('.controls').append('<span class="help-inline">' + message + '</span>');
}
};
$(function () {
$("form :input").focusout(function() {
if(Nette.validateControl(document.getElementById(this.id))) {
$(this).closest('.control-group').removeClass('error').find('.help-inline').remove();
};
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment