AlexSergeev1990,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
.err {
border: 4px red solid;
}
</style>
<script>
window.addEventListener("DOMContentLoaded", function() {
var tovar = [].slice.call(document.querySelectorAll('[name="tovar"]'), 0);
tovar.forEach(function(item, i) {
item.addEventListener("input", function() {
var val = this.value.trim(), err = val && tovar.some(function(el, k) {
el = el.value.trim();
return k != i && el && el == val;
});
err ? item.classList.add("err") : item.classList.remove("err");
});
});
});
</script>
</head>
<body>
<input type='text' name='tovar'/>
<input type='text' name='tovar'/>
<input type='text' name='tovar'/>
</body>
</html>