mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 17:51:13 +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();
|
$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);
|
||||||
|
|
Loading…
Reference in a new issue