Fixed the JavaScript form validation logic from isValid && validateXxx() to validateXxx() && isValid, in order to correctly validate multiple fields at once.

This commit is contained in:
依瑪貓 2021-08-27 07:37:09 +08:00
parent 62b59e7380
commit a0382ad179
2 changed files with 10 additions and 10 deletions

View File

@ -97,8 +97,8 @@ function updateParent(code) {
*/
function validateForm() {
let isValid = true;
isValid = isValid && validateCode();
isValid = isValid && validateTitle();
isValid = validateCode() && isValid;
isValid = validateTitle() && isValid;
return isValid;
}

View File

@ -338,26 +338,26 @@ function resetRecordButtons() {
*/
function validateForm() {
let isValid = true;
isValid = isValid && validateDate();
isValid = validateDate() && isValid;
$(".debit-record").each(function () {
isValid = isValid && validateRecord(this);
isValid = validateRecord(this) && isValid;
});
$(".credit-account").each(function () {
isValid = isValid && validateRecord(this);
isValid = validateRecord(this) && isValid;
});
$(".record-account").each(function () {
isValid = isValid && validateAccount(this);
isValid = validateAccount(this) && isValid;
});
$(".record-summary").each(function () {
isValid = isValid && validateSummary(this);
isValid = validateSummary(this) && isValid;
});
$(".record-amount").each(function () {
isValid = isValid && validateAmount(this);
isValid = validateAmount(this) && isValid;
});
if (isTransfer()) {
isValid = isValid && validateBalance();
isValid = validateBalance() && isValid;
}
isValid = isValid && validateNote();
isValid = validateNote() && isValid;
return isValid;
}