Last active
August 29, 2015 14:18
-
-
Save jprieton/8ed84b4e74cc785a6703 to your computer and use it in GitHub Desktop.
Validation engine + bootstrap
This file contains 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
$(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