Add new error handling

This commit is contained in:
aignatov-bio 2020-01-16 10:51:37 +01:00
parent b116c3720c
commit 96e1d4a7d0

View file

@ -25,12 +25,6 @@ var renderFormError = function(ev, input, errMsgs, clearErr, errAttributes) {
$form.clearFormErrors(); $form.clearFormErrors();
} }
// Mark error form group
var $formGroup = $(input).closest('.form-group');
if (!$formGroup.hasClass('has-error')) {
$formGroup.addClass('has-error');
}
// Add error message/s // Add error message/s
var errorText = ($.makeArray(errMsgs).map(function(m) { var errorText = ($.makeArray(errMsgs).map(function(m) {
if( m instanceof Array ) { if( m instanceof Array ) {
@ -40,6 +34,19 @@ var renderFormError = function(ev, input, errMsgs, clearErr, errAttributes) {
} }
})).join('<br />'); })).join('<br />');
if ($(input).hasClass('sci-input-field')) {
$(input).closest('.sci-input-container').addClass('error');
$(input).closest('.sci-input-container').attr('data-error-text', errorText);
return;
}
// Mark error form group
var $formGroup = $(input).closest('.form-group');
if (!$formGroup.hasClass('has-error')) {
$formGroup.addClass('has-error');
}
var $errSpan = "<span class='help-block'" + var $errSpan = "<span class='help-block'" +
errAttributes + '>' + errorText + '</span>'; errAttributes + '>' + errorText + '</span>';
$(input).after($errSpan); $(input).after($errSpan);