mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 09:42:46 +08:00
Add new error handling
This commit is contained in:
parent
b116c3720c
commit
96e1d4a7d0
1 changed files with 13 additions and 6 deletions
|
@ -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('<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'" +
|
||||
errAttributes + '>' + errorText + '</span>';
|
||||
$(input).after($errSpan);
|
||||
|
|
Loading…
Reference in a new issue