may be caused by using a mixture of ==
and ===
. I recommend trying the following code first:
function validateForm() { console.log("Validation running"); if (jobSubmission.jobCategory === 'Please-Select' || jobSubmission.jobCategory === undefined) { alert("Please make a job category selection"); return false; } if (jobSubmission.salaryRange !== null && jobSubmission.timeOfPayment === undefined) { alert("Please select the frequency of salary payment or remove the salary range"); return false; } return true; }
If the problem persists, I recommend checking the jobSubmission object in the console log and making sure the value you are checking is as expected.