1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-27 02:09:59 +00:00
Radarr/UI/jQuery/Validation.js
2013-08-20 18:07:48 -07:00

30 lines
897 B
JavaScript

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();
};
});