JSFiddle - React, Tailwind, and code Playground
HTML
<input type='text' name='tovar[]' data-uniqu-group="first"/>
<input type='text' name='tovar[]' data-uniqu-group="first"/>
<input type='text' name='tovar[]' data-uniqu-group="first"/>
CSS
input{
display:block;
}
.invalid{
border:solid 1px red;
}
JavaScript
$('[data-uniqu-group]').on('input',function(){
var $this=$(this).removeClass('invalid');
$('[data-uniqu-group="'+$this.data('uniqu-group')+'"]').each(function(){
if(this!==$this.get(0) && this.value==$this.val())
$this.addClass('invalid');
});
});