Skip to content

Instantly share code, notes, and snippets.

@jprieton
Last active August 29, 2015 14:18
Show Gist options
  • Save jprieton/8ed84b4e74cc785a6703 to your computer and use it in GitHub Desktop.
Save jprieton/8ed84b4e74cc785a6703 to your computer and use it in GitHub Desktop.
Validation engine + bootstrap
$(function () {
jQuery('#formID').validationEngine('attach', {
showPrompts: false,
showArrow: false
}).bind("jqv.field.result", function (event, field, errorFound, prompText) {
var formGroup = field.parents(".form-group");
formGroup.removeClass("has-feedback has-error has-success");
if (errorFound) {
formGroup.addClass("has-feedback has-error");
jQuery(formGroup).find("span.help-block, span.form-control-feedback").remove();
formGroup.append('<span class="glyphicon glyphicon-remove form-control-feedback"></span>');
formGroup.append('<span class="help-block message">' + prompText + '</span>');
}
else {
formGroup.addClass("has-feedback has-success");
jQuery(formGroup).find("span.help-block, span.form-control-feedback").remove();
formGroup.append('<span class="glyphicon glyphicon-ok form-control-feedback"></span>');
}
});
$('#formID').ajaxFormSubmit({
alertContainer: '#alert-container'
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment