I'm trying to get a value from a select and if it is bad selection you get an error. For example:
<select name = "dogs" id = "dogs">
<option value="dog1">Dog 1</option>
<option value="dog2">Dog 2</option>
<option value="cat1">Cat 1</option>
</select>
If someone selected cat1, they would get an error.
var x = document.getElementById("dogs");
var dogInspector = x.options[x.selectedIndex].value;
if(document.forms['form1'].dogInspector.value === "cat1"){
document.getElementById("validate").innerHTML = "No cats allowed!";
return false;
}
I'm unsure why this isn't working? Is it the if statement?