scinote-web/app/assets/javascripts/sitewide/form_cleanups.js
wandji a1e6392a45
Fix bugs with jquery3 upgrade [SCI-8973] (#5933)
* Fix bugs with jquery3 upgrade [SCI-8973]

* Remove deprecated jquery method (.error, .completed, .success) [SCI-8973]

* Fix linter error [SCI-8973]
2023-08-09 10:33:58 +02:00

23 lines
706 B
JavaScript

$.fn.clearFormErrors = function () {
$(this).find('.nav.nav-tabs li').removeClass('has-error');
$(this).find('.form-group').removeClass('has-error');
$(this).find('span.help-block').remove();
};
$.fn.clearFormFields = function () {
$(this).find("input")
.not("button")
.not('input[type="submit"], input[type="reset"], input[type="hidden"]')
.not('input[type="radio"]') // Leave out radios as this messes up Bootstrap btn-groups
.val('')
.attr('checked', false)
.attr('selected', false);
};
$.fn.removeBlankFileForms = function () {
$(this).find("input[type='file']").each(function () {
if (!this.files[0]) {
$(this).closest("fieldset").remove();
}
});
}