Hi all how could I insert a (if) statement to this code that if (element1) value is not blank then (element2) is required before submitting.
I'm already using a list of validated element that needs to be filled before subtitling
I would like to add a few more to that list depending on if some element are not empty.
Here's part of the code I'm not sure how or where to inset the if statement.
function submitBotton() {
var tool1 = document.getElementById("OtherEquipment1").value
if (tool1 !== '') {
toolowner1: "Equipment Owner is required!",
}
var toValidate = {
prefDate: "Date is required!",
Person: "Name is required!",
Loc: "Location is required!",
Time: "Time is required!",
};
var idKeys = Object.keys(toValidate);
var allValid = true;
idKeys.forEach(function(id) {
var isValid = checkIfValid(id, toValidate[id]);
if (!isValid) {
allValid = false;
}
});
if (allValid) {
addRecord();
}
}
Thanks