I have the following:
function validateInput(departmentArray) {
let isValid = true
const array = Object.keys(departmentArray)
for(let i=0; i < array.length; i++) {
keyname = array[i]
if (departmentArray[keyname] === '') {
const errorMsg = `Missing \'${keyname}\' on form`
isValid = false
$('#`keyname`').toggleClass('warningBox')
}
}
return isValid
}
The keyname
that errors out due to being empty needs to be given a red box around in the HTML. I have tried
$('#`keyname`').toggleClass('warningBox')
and variations thereof. How do I address the keyname with JQuery to be able to change its CSS ?