var form = document.getElementsByTagName('form')[0];
var field = document.querySelectorAll('input[class^="loc-"]');
var error = document.querySelectorAll('.error');
form.addEventListener("submit", function (event) {
for (var i=0; i < 3; i++) {
if (field[i].value == 0) {
error[i].className = "error active";
event.preventDefault();
}
}
}, false);