Added the validateRecord() validation in the JavaScript of the transaction form, so that users have to explicitly delete the invalid records before submitting the form in the accounting application.

This commit is contained in:
依瑪貓 2020-08-08 11:25:51 +08:00
parent 1f0ec979ae
commit 61da336188

View File

@ -338,6 +338,12 @@ function resetRecordButtons() {
function validateForm() {
let isValidated = true;
isValidated = isValidated && validateDate();
$(".debit-record").each(function () {
isValidated = isValidated && validateRecord(this);
});
$(".credit-account").each(function () {
isValidated = isValidated && validateRecord(this);
});
$(".record-account").each(function () {
isValidated = isValidated && validateAccount(this);
});
@ -374,6 +380,18 @@ function validateDate() {
return true;
}
/**
* Validates the record.
*
* @param {HTMLLIElement} record the record
* @returns {boolean} true if the validation succeed, or false
* otherwise
* @private
*/
function validateRecord(record) {
return !record.classList.contains("list-group-item-danger");
}
/**
* Validates the account column.
*