can display server-side errors on the UI.

This commit is contained in:
Keivan Beigi 2013-08-20 18:07:48 -07:00
parent 43baa2b86e
commit 9195dc6de5
7 changed files with 740 additions and 3 deletions

30
UI/jQuery/Validation.js Normal file
View file

@ -0,0 +1,30 @@
define(
[
'jquery'
], function ($) {
'use strict';
$.fn.addBootstrapError = function (error) {
var input = this.find('[name]').filter(function () {
return this.name.toLowerCase() === error.propertyName.toLowerCase();
});
var controlGroup = input.parents('.control-group');
if (controlGroup.find('.help-inline').length === 0) {
controlGroup.find('.controls').append('<span class="help-inline error-message">' + error.errorMessage + '</span>');
}
controlGroup.addClass('error');
return controlGroup.find('.help-inline').text();
};
$.fn.removeBootstrapError = function () {
this.removeClass('error');
return this.parents('.control-group').find('.help-inline.error-message').remove();
};
});