* Finish task #84584.

This commit is contained in:
liumengyi
2023-02-16 05:28:39 +00:00
parent 020b742dc7
commit 9be6fa2fd2
5 changed files with 83 additions and 130 deletions
+49
View File
@@ -1,3 +1,11 @@
$(function()
{
$('input').on('change', function()
{
$(this).removeClass('has-error');
$(this).closest('td').find('.text-danger.help-text').remove();
});
});
/**
* Add item to create view of programplan.
*
@@ -30,3 +38,44 @@ function deleteItem(obj)
if($('#planForm .table tbody').children().length < 2) return false;
$(obj).closest('tr').remove();
}
/**
* Add row errors.
*
* @param array $rowErrors
* @access public
* @return void
*/
function addRowErrors(rowErrors)
{
var errorFieldID, errorTip, errorHTML;
$('.text-danger.help-text').remove();
$('input').removeClass('has-error');
var index = 0;
var alterError = '';
$('input[name^=names]').each(function()
{
if($(this).val() == '') return true;
if(typeof rowErrors[index] == 'object')
{
for(var errorField in rowErrors[index])
{
$errorTD = $(this).closest('tr').find('input[name^=' + errorField + ']').closest('td');
errorTip = rowErrors[index][errorField];
errorHTML = '<div id="help' + errorField + index + '" class="text-danger help-text">' + errorTip + '</div>';
$errorTD.append(errorHTML);
$errorTD.find('input').addClass('has-error');
}
}
if(typeof rowErrors['percent'] == 'string')
{
errorFieldID = $(this).closest('tr').find('input[name^=percent]').attr('id');
errorHTML = '<div id="help' + errorFieldID + '" class="text-danger help-text">' + rowErrors['percent'] + '</div>';
$('#' + errorFieldID).closest('td').append(errorHTML);
$('#' + errorFieldID).closest('td').find('input').addClass('has-error');
}
index ++;
});
}