From 96e1d4a7d0c2679fb3a1cc6bb1ba51f70e6d7dc3 Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Thu, 16 Jan 2020 10:51:37 +0100 Subject: [PATCH] Add new error handling --- .../javascripts/sitewide/form_errors.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/sitewide/form_errors.js b/app/assets/javascripts/sitewide/form_errors.js index e62972481..2db026ef3 100644 --- a/app/assets/javascripts/sitewide/form_errors.js +++ b/app/assets/javascripts/sitewide/form_errors.js @@ -25,12 +25,6 @@ var renderFormError = function(ev, input, errMsgs, clearErr, errAttributes) { $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 var errorText = ($.makeArray(errMsgs).map(function(m) { if( m instanceof Array ) { @@ -40,6 +34,19 @@ var renderFormError = function(ev, input, errMsgs, clearErr, errAttributes) { } })).join('
'); + + 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 = "' + errorText + ''; $(input).after($errSpan);