Skip to content

Commit

Permalink
Clean up logic for validating recon form required fields
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMwashuma committed Nov 5, 2024
1 parent 4ac9ca2 commit 3f2a76c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tally_ho/apps/tally/static/js/blank_field_check.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
function validate_results(alertMessage) {
const requiredElements = document.querySelectorAll('.required-input');
let allFilled = true;
console.log({ requiredElements })
let isFormValid = true;
requiredElements.forEach(el => {
const inputChild = el.querySelector('input');
if (inputChild && inputChild.value.trim() === '') {
allFilled = false;
isFormValid = false;
el.classList.add('has-error');
} else if (inputChild) {
el.classList.remove('has-error');
}
});

if (!allFilled) {
if (isFormValid === false) {
alert(alertMessage);
return false;
return isFormValid;
}
return true;
return isFormValid;
}

0 comments on commit 3f2a76c

Please sign in to comment.