I'm trying to validate some code via javascript. The drama I am having is that I receive an
"Uncaught TypeError: Cannot set property 'border' of undefined".
I am new to javascript and trying to get a full understanding of why this happens and how to prevent this in future coding projects. My goal is if the validation fails it changes the text box border to red.
function validation_Step1(event) {
var Firstbox = document.getElementsByName("Firstbox");
if (Firstbox.value == null || Firstbox.value == '') {
document.getElementsByName("Firstbox")
.style.border = "2px solid red";
alert("Error");
return false;
} else {
return true;
}
}